Recent Articles

Jan 2022

Two Addresses

by in CodeSOD on

When passing data over the wire, we frequently want to aggregate that data into a data transfer object. An ideal DTO lets a client get all the data they need in a single request, without needing lots of round trips to get related objects.

Or, you could be like the contractors that Marty had to work with, and get handed this Java code:


Time After Time

by in Error'd on

This week's submissions really aren't about time, they've just been sitting around a bit and need to get used up before they go bad. Or as the maestro used to say: "You might as well eat it... I'm only going to throw it away!"

An anonymous reader waffles "I do want to answer but I'm only half sure."


Three Links

by in CodeSOD on

Brian's hired a contractor to tackle a challenging technical problem: they wanted to display three links in three table cells. Now, you or I might just write that as HTML. But if we did that, we'd lose the opportunity to do this in JavaScript. Plus think of all that repetition- you'll be outputting a <td></td> tag pair three times. That's just wasteful.

No, what we need is some elegant JavaScript solution that solves this problem without any unnecessary repetition.


Modernization

by in Feature Articles on

Contract Lifecycle Management

Micki worked for ConCom, a huge multinational development consulting company with offices on four continents. ConCom, in turn, assigned Micki's team to another multinational corporation, one that was looking for an ERP upgrade. Picture six developers in one little loft office, complete with dartboard, while the architects, POs, SMs, and the like were on another continent in a totally different time zone. At first they worked small tasks, proving themselves capable of being assigned the big upgrade project, and eventually, details started to come out of what the client really wanted.


Convenience

by in CodeSOD on

Casey works with some pretty courteous and forward thinking Python developers. They want to make sure that using their APIs are as convenient as possible, and make sure to provide all sorts of useful convenience methods. Like this one:

@property def request(self): """ just for convenience """ return self

Every Change

by in CodeSOD on

Now, I'm an old luddite who still looks askance at cloud services, but I'm willing to recognize their value. Still, I worry about whether I can trust that vendor to actually deliver the services I need, without them suddenly shoving out breaking changes which screw me, but maybe not their "whale" customers where the real money is.

That's something which "Sleeper" got to grapple with last fall. They use Amazon's Athena service, which allows software to query S3 buckets using SQL syntax. Late last year, "Sleeper" got an email which they forwarded to us with the subject "This should be fun". The email started like this:


Time Enough to Cry

by in Error'd on

Does anybody really care about time?

Angela A. cares. "TGI(T|F)" she announces. "The days just run together!"


Commentary

by in CodeSOD on

"Include descriptive comments for each method," isn't bad advice. I mean, ideally, the method name and parameters would be descriptive enough that you don't need to add lots of comments, but more comments is rarely going to hurt things. Unfortunately, "include descriptive comments" usually decays into "include comments". And that's how we get piles of code like this one, from Patrick:

// // Function name : CZiArecaRaidController::ReadAllRaidsetInfo // Machine : w7gre7 // Environment : Visual Studio .Net 2008 // doxygen : /// \fn CZiArecaRaidController::ReadAllRaidsetInfo(BSTR ContextInfo, IZiArecaDataCollection *pRaidsetInfoCollection, IZiArecaDataCollection *pVolumesetInfoCollection, IZiArecaDataCollection *pPhysicalDriveInfoCollection) /// \brief /// \details /// \param ContextInfo /// \param *pRaidsetInfoCollection /// \param *pVolumesetInfoCollection /// \param *pPhysicalDriveInfoCollection /// \return STDMETHODIMP /// \author (redacted) /// \date 24.01.2011 09:59:10 // STDMETHODIMP CZiArecaRaidController::ReadAllRaidsetInfo(BSTR ContextInfo, IZiArecaDataCollection **pRaidsetInfoCollection, IZiArecaDataCollection **pVolumesetInfoCollection, IZiArecaDataCollection **pPhysicalDriveInfoCollection) { // ... } // // Function name : CZiArecaRaidController::GetArecaErrorMessage // Description : // Return type : string // Argument : ARC_STATUS stat // Author : (redacted) // Machine : Lapgre5 // Environment : Visual Studio .Net 2005 // Date/Time : 05.06.2007 15:24:53 // string CZiArecaRaidController::GetArecaErrorMessage(ARC_STATUS stat) { // ... }

Document Soup

by in Feature Articles on

An Enterprise Resource Planning system needs to keep track of your enterprise resources. Many of those resources, especially the expensive ones, need lots of documents tracked about them- inspections, service reports, maintenance bills, etc. So the ERP and the Document Management System need to talk.

Years ago, for Coyne, this presented a few problems. First, the ERP was a mainframe application running on an IBM mainframe. Second, it was getting retired. Third, the DMS didn't talk directly to it, but instead communicated through a terminal emulator and used configuration files to correctly parse the screen contents coming back from the mainframe.


The Tech Lead

by in Feature Articles on

Years ago, Karthika was working as a contractor. She got hired on to develop an intranet application for a small government project. The website in question was already in use, and was absolutely mission critical for the organization, but it also had a very small user base- roughly five users depended on this application.

When Karthika started, she immediately encountered a few surprises. The first was the size of the team- 8 developers, including a Team Lead. That seemed like a large team for that small number of users, and that didn't even include the management overhead. The code base itself was similarly oversized; while the product was important, it was a pretty prosaic CRUD app with a few tricky financial calculations involved.


Classic WTF: The Old Ways

by in CodeSOD on
It's a holiday in the US today, so we're taking a trip into the past for a haunting classic about how things used to be. Original. -- Remy

Greg never thought he’d meet a real-life mentat.

“We’re so happy to have you aboard,” said Jordan, the CEO of IniTech. She showed Greg to the back end of the office, to a closed door marked with just one word: Frank. Jordan, not bothering to knock, opening the door.


Up Up Down Down Left Right Left...

by in Error'd on

...Right B A. Right? Every so often, someone sends us a submission with a hidden agenda. Of course we get the usual solicitations for marriageable exotic beauties and offers to trade linkspam locations. But then there are the really interesting ones. Maybe they're legitimate, maybe they're photoshopped or otherwise faked, and maybe they're an attempt to bypass someone's ban on political propaganda or quack science. In any case, there isn't any of that here this week, but we're saving them up and maybe we'll feature a future issue of spot the fraud for you.

First up is dog lover George with a hysterical spam-blocking email address, sharing a help message that must have been crafted by Catbert himself. "My sixty seconds of glory awaits!" he howls, but then whimpers "I will be real disappointed if the agent isn't [Gone in Sixty Seconds headliner] Nicolas Cage."


A Pointer to your References

by in CodeSOD on

John C works at a defense contractor, and his peers are well versed in C. Unfortunately, many years ago, a lot of their software started being developed in Java. While references are often described as "pointers, but safer," they are not pointers, so your intuitions about how memory gets allocated and released are likely to be wrong.

Which is definitely the case for John's peers. For example, in C, you generally want really clear understandings of who owns a given block of memory. You don't want to allocate memory and hand it off to another module without being really clear about who is responsible for cleaning it up later. This means that you'll often write methods that expect buffers and other blocks of memory passed into them, so that they don't have to worry about memory ownership.


A Basic Print Algorithm

by in Feature Articles on

Common snail

In the late 90s, Aaron was employed at a small software company. When his coworker Mark submitted a letter of resignation, Aaron was assigned to maintaining the vast system Mark had implemented for an anonymous worldwide company. The system was built in the latest version of Visual Basic at the time, and connected to an Oracle database. Aaron had never written a single line of VB, but what did that matter? No one else in the company knew a thing about it, either.


The Correct Browser

by in CodeSOD on

Sometimes, it's not the code that's bad, but what the code costs. For Elizabeth's company, that cost was significant in terms of dollars and cents. They needed to staff up to accomplish some major Java Enterprise work, so they went with the highest of the highly paid consultants they could find. These consultants came from a big name firm, and were billed at an eye-watering hourly rate.

Elizabeth warns us that the Java code is a behemoth of WTFs that is "too difficult to describe", but one particular WTF leapt out at her. Specifically, included in the application was a file called nonIEUser.html. This project was happening circa 2012, which is after Microsoft finally admitted standards might need to be a thing, and definitely well outside of the time when your web application should only work in Internet Explorer. For a greenfield project, there was no reason to do anything IE only, and fortunately, they didn't- aside from forcing a check to yell at you if you didn't use IE.


The New Management

by in Feature Articles on

For a young college graduate in the early 80s, Argle was fortunate to already have some real-world experience. That served him well, because businesses which were looking towards the future were already looking into how they could improve their automation with the new and relatively cheap computer systems that were hitting the market.

One such company was a family-owned, multi-generational manufacturing company. They had a vision for the future, and the future involved the latest in CNC milling machines and robotic manufacturing. They needed the team that could send them into the future, and were hiring to build that team.


Everything Old is New Again

by in Error'd on

Whenever there's a major change in the world, it always takes application developers a little time to adjust. Remember when the US government thought it would be a great idea to mess around with their Daylight Saving Time schedule with only two years warning? (I'm guessing nobody remembers the fiddling done by earlier administrations because they were too young to care, or not born yet.) Two years warning probably seemed like plenty to non-technical legislators, not thinking about all the software that was in place with built-in calendars. Well, someone has apparently decided to one-up a measly time change, by inventing something called a New YEAR. This resets the entire calendar, and it must be a novel practice because surely websites wouldn't break due to some routine event that has been happening for at least a dozen years or more, right? Right?

Aspiring Poké trainer Valts S. began a long long time ago far far away.


Well Trained

by in CodeSOD on

Mandatory compliance training is a thing. The reasons behind it range from companies trying to reduce civil liabilities to actual legal mandates which require the training. The quality of mandatory training ranges from "useless" to "actively awful", and it's mostly PowerPoint-style slides interspersed with quizzes to make sure you were "paying attention". The worse ones will usually have timers on the slides so you can't just click past, and have to actually idle to "force" you to read it.

Also, since legal compliance tends to move slower than technology, training built years ago is frequently still relevant. So, for example, Duncan's company built training back when you could reasonably expect Flash to run in the browser. Building the training and the content cost money, so once Flash got deprecated, they weren't just going to throw that money away- they found a contractor who'd convert it to "HTML5".


Do Nothing

by in CodeSOD on

Ivan encountered a strange bug. His organization uses the R language, which has a handy-dandy documentation language attached to it, for Rd files. The language itself is an organically grown hodge-podge of R and LaTeX, built to make it easy to format both plain text and R code within the documentation. It lets you use LaTeX-like commands, but also mix in R code to control the output.

Ivan's problem was that one of his macros, which we'll call \mymacro, only worked sometimes. The specific cases where it failed were where the macro expanded into multi-line output, which once upon a time wasn't a thing that Rd supported, but is supported, and clearly wasn't the problem. Ivan poked at it from that direction, suspecting there was maybe a regression, and then spent a lot of time trying to understand the places where the macro did and didn't work.


Cloudy Optimizations

by in CodeSOD on

Search engine optimization is both a dark art and a corrupt industry. Search providers work hard to keep their algorithms opaque. SEO is a mix of guessing and snake oil and sometimes outright lying.

For example, Mark M recently inherited a rather… bad PHP website. One of its notable SEO tweaks was that it had a tag cloud that slapped a bunch of keywords together to give a sense of what kinds of articles had been posted recently. At least, that was the idea. But when Mark dug into the code, there was no sign that there was any source of tags in the database. In fact, articles didn't get tagged at all. So where was the tag cloud coming from?


My Many Girlfriends

by in Feature Articles on

In the long ago, wild-west days of the late 90s, there was an expectation that managers would put up with a certain degree of eccentricity from their software developers. The IT and software boom was still new, people didn't quite know what worked and what didn't, the "nerds had conquered the Earth" and managers just had to roll with this reality. So when Barry D gave the okay to hire Sten, who came with glowing recommendations from his previous employers, Barry and his team were ready to deal with eccentricities.

Of course, on the first day, building services came to Barry with some concerns about Sten's requests for his workspace. No natural light. No ventilation ducts that couldn't be closed. And then the co-workers who had interacted with Sten expressed their concerns.