Feed the-daily-wtf The Daily WTF

Favorite IconThe Daily WTF

Link http://thedailywtf.com/
Feed http://syndication.thedailywtf.com/TheDailyWtf
Updated 2024-11-21 14:46
CodeSOD: Extra Documentation
Tony works in a shop that makes extensive use of XMLDocs comments. Now, it's no surprise that many of the comments take the form:
CodeSOD: In the Area (code)
Jeremy was sent hunting a bug in some older JavaScript code. The key problem was that many phone numbers were getting a US country code prepended to them, even when they already had a different country code and were in a different country than the US.
Error'd: Boy Howdy
A couple of mojibakes and onlyone really awful pun this week. This editor was in Texas for the week and just can't escape the John Wayne references.Long-time listener, first-time callerBruno shared his first submission after 20 years and ran into abit of a hitch, which we're saving for a special episode. But here's his historic snark:"It's not that often that we see errors in Big Name Games on TDWTF.Well, the lastest heir to the Borderlands series of games is Tiny Tina Wonderland, and it delivers.Of course, it also delivers a way to optimize your inventory, because that's in the Borderlands genes.However, this was an [endgamebold] first: I still kept the legendary, sorry ;-)" Thanks, Bruno!
CodeSOD: An Incremental Replacement
Jon sends us an entire function, but I'm just going start with the comment, after which you'll understand everything bad about this without me explaining further. Don't worry, I will, but the comment says it all:
CodeSOD: Bubbled to the Top
What makes code bad? Is it an inherent property of the code itself? Or is it the context in which the code is placed?For example, let's look at this function, found by Lars.
CodeSOD: Dining on Leftovers
Sometimes, you go up to the fridge, looking for a snack, and see the array of leftovers, and your appetite fails you. You want to eat, you know you have plenty of options that you just need to throw into the microwave, but none of them look appetizing. Leftovers always seem like a better idea when you're busy making them than when you're trying to deal with them after the fact.Stev's co-worker has left them a large pile of leftovers. This block is representative of all the half-finished leftovers that don't do anything and shouldn't be there, but happily make it much harder to understand the codebase:
CodeSOD: Randomly Generated
There was an era, briefly, where corporations flirted with the idea of replacing their web based UIs with Flash. There were even UI frameworks, like Flex, built to support that kind of migration. Yes, it was a disaster.But not quite as much of a disaster as this action script code that Daniel found. At some point, someone at Initech decided they needed to implement a random number generator. This is what they came up with:
Error'd: NaaN
NaaN stands for NaN Ain't A Number. But other things most certainly are,even though we don't always think of them as numbers or represent them as decimals. MCMLXVI, for example.Sometimes zero. Maybe even more so 5-i. This week we have some specialnumbers for you, among other things.Lonely dog-lover Kevin M. was thrown from joy to despair in barely one second."Embark found some new relatives for my dog... or not." It's arguablytechnically true that Embark found a number of new pup kin.
CodeSOD: Get Selected
Matt is supporting an old VB.Net application. This representative line highlights the overall code quality:
CodeSOD: Providing Authentication
Paulette's team had built a wrapper method around the C# authentication APIs that acted as a convenience function. Called GetAuthenticationProvider, it accepted two parameters. The first, a string, could be used to look up the provider's type in a lookup table. The second was a boolean, which indicated whether it should be an local authentication provider, or an external provider (e.g., OAuth). At least, that's what the documentation says.The function would find and/or construct the correct type of provider, and return it. They all shared an interface, so this all should work just fine.But Paulette was left trying to understand the reasoning that lead to this line:
CodeSOD: Random Permutation
Gary inherited some C code. This C code is correct, and does what it is supposed to, which is itself a pretty straightforward problem: create an array of values from 0-N, arranged in a random order.Now, there are a lot of possible ways to do this, most of which involve swapping cells in the array around. It's quick, efficient, and easy to understand. Which means Gary's co-worker needed to find a better solution.
CodeSOD: Projection Your Failures
Geoinformatics ends up needing to deal with a pretty thorny problem: projecting a sphere onto a 2D coordinate system. There is no single correct way to do this, and depending on many factors, you may need to choose different projections- for maps covering small regions, the curvature of the Earth might have only a minor effect; the curvature is different depending on your latitude; depending on your needs, you might need different projections that prioritize retaining (or discarding) certain relationships between map coordinates.Given how hard this problem is, people have put a lot of time and effort into solving it with some standards. In this case, the standard is EPSG codes, a registry of reference systems, different values for the shape of the Earth, and different coordinate systems, all granted a unique identifier in the range 1024–32767.Each possible coordinate system has a different range of possible coordinates, and the coordinates mean wildly different things, so it's important to make sure that any coordinate you're passing around has its EPSG code attached to it. If you don't, the coordinate value is basically meaningless.Well, it's basically meaningless unless you're Samantha's co-worker, who came up with a "clever" solution for figuring out the ESPG code for a coordinate:
Error'd: Bon Weekend
Jobhunter Quentin G. is finding the current labor market to be very challenging. Says he: "The job sounds cool, but that would be quite a salary cut."
CodeSOD: Regular Query String
Robert H is taking the first steps required to make existing code supportable: writing unit tests. The code in question isn't that old, it was just developed by someone who didn't care about mundane tasks, like testing.They also didn't care about things like paying attention to web standards, and thus were using the same copy/pasted utility functions they'd been using for a decade.The application in question was a web application with a large amount of client side code. The navigation system would construct a URL with a query string, then programatically alter the window.location.href property, triggering a page load.Now, since circa 2016, the "correct" way to manipulate search parameters in every browser that wasn't Internet Explorer is through the URLSearchParams object, which gives you handy-dandy get and set methods, along with some iterators.Some organizations might have been (or might still be- the horror!) supporting IE. But that doesn't really apply to Robert's case. But even if one were supporting a legacy browser, this pile of string mangling probably isn't the right way to do it:
CodeSOD: Self-Documentation
It's rare to find truly self-documenting code. Adam, however, while hunting down a bug, found some.Adam was trying to understand exactly where some functionality was coming from in a Java program. The code base had some very long inheritance trees, which was an absolute nightmare for maintenance. The mix of overridden methods and mysterious interfaces and dependencies from the lowest levels of the hierarchy all the way back to the top created some of the most spaghettied spaghetti code you could imagine.While investigating, Adam found this wonderful piece of self-documenting code, sitting right at the top:
CodeSOD: Constantly Named
We’ve seen constants in the form of static final int ONE = 1 before. At this point, it’s barely worth discussing, it’s become so common. But Susan has found us yet another unique twist on the subject.It started when a contractor wrote Java code that looked like this:
CodeSOD: Uniquier
Sole Purpose of Visit's team had a simple enough problem: they needed to generate unique labels for widgets on the screen. These widgets just need those unique IDs for internal purposes, so a simple incrementing counter would have been sufficient.That isn't the direction they went in.
Error'd: Free Peach
In English we have common greetings and farewells thatmark salubrious moments in time, such as "Good Morning","Good Evening", "Good Afternoon", even "Happy New Year"or "Happy Birthday". The same is true for every tonguewith which I am even slightly familiar, to the point Iwill wager that it is common to every human language onthe planet. And yet, despite the invention of "le weekend"at least a century ago (variously attributed tolabour unionists, Henry Ford, or a nomadic monotheist),even the French have not yet penned a pithy phrase to herald the end of our conventional working week.
CodeSOD: Select Your Dropdown
Francisco's co-worker needed to populate a dropdown with three items: "--All--", "Accepted", and "Pending". Unfortunately for this co-worker, a basic understanding of "array literals" or "lists" or, well, any collection type was slightly beyond their grasp. Instead, they chose to do what many a developer who doesn't understand the date/time functions of their languages does: ask the database for help:
CodeSOD: In House Refactoring
Today's submitter works for a company that has a history of outsourcing pretty much all development, and to the lowest bidder, at that. This resulted in some terrible code, complete with 30,000 line classes, so the company decided to bring development back in house and clean up the code.After three years of hard work, the in-house team was proud to announce their new, more maintainable, version of the code. Unfortunately, they didn't have the best sense of what maintainable looked like, so their Java code had methods with signatures like this:
CodeSOD: Changing the Type of Newbie
Today's story isn't really a WTF. No, Phil R was mentoring a new developer, and as such, Phil was sending some simple, easily scoped Python tasks over to that developer. After a few really low hanging fruit, Phil gave the Newbie a trickier one. The contact_type field was currently a string. That was a mistake, and it needed to be changed to a number. The change would involve a whole bunch of find-and-replace, but mostly it was just changing strings like '07' into 7.Newbie trotted off, and found this code block:
The View From Your State
April Fool's Day happened over the weekend, which means no April Fool's Day post. I mean, I could have, but instead, I thought it would be fun to look into something that, once upon a time, wasn't a WTF, but honestly, always should have been.Our story starts with Jake, a relatively modern web developer, who was helping another developer, Jane, build a site-scraper for a local government's site. See, the government site couldn't be bothered with anything like RSS, so if you wanted a list of upcoming events, notifications, or other information, your only option was to load the page manually, or whip up a site-scraper that automated extracting that information.The problem was, Jane was finding some absolute nonsense in the HTML of the page, and it was incredibly difficult to parse out the information they were looking for. "What? How hard could this possibly be?" Jake wondered. He opened the site, viewed source, and was greeted with this:
Error'd: Time For (a cool change)
Without much ado, five minidoozies follow.If it isn't one thing it's another, for our regular Argle Bargle."I looked outside. Everything was soggy and I could hearclaps of thunder. How long will it last? Click on weatherand... um... Fire Weather? I can think of only one wayI'm getting a fire going in my backyard right now and itinvolves a flamethrower." It's better than tornadoes!
CodeSOD: Exceptional Messages
Structured exception handling is an excellent way to handle errors, but wouldn't it be nice if you could execute a different branch of code depending on what specific error just happened? It's a pity that there's just no possible way to filter exceptions using the good old fashioned try and catch. Fortunately, Mateusz has a co-worker who invented that wheel for us.
CodeSOD: Closely Related
Relational databases were at one time an absolute standard that nearly any developer could be expected to be familiar with. These days, it's still valuable knowledge, but it's less surprising when someone doesn't know more than the basics- there are so many other ways one might persist data, each with their own tradeoffs. But if someone is developer for a contracting firm specializing in data driven applications, you would expect them to have a little more grounding in RDBMSes than the average developer. Well, you would expect that if you thought the contracting firm was actually selling a valuable service, instead of trying to bilk their customers and their contractors and hope nobody notices.The important things about RDBMSes is that each table represents a relation- a set of fields that are all conceptually related, like "Employee" (with an employee ID, a name, a hire date, etc.) or "SalesListing" (with a product description, a price, etc.), and then those tables can have relationships to other tables- foreign keys that guarantee that if "SalesListing" has a "SalesRep" field on it, that "SalesRep" has a matching entry in the "Employee" table.Roman received some SQL code from one such contracting firm that perhaps highlights where these sorts of things might go wrong:
CodeSOD: An Accountable Service
While the world has switched to RESTful APIs, the magical power of SOAP-based web-services was that they made code generation easy. Well, easy-ish. Well, easy when it worked right, and then hard the rest of the time. But if it worked, if the WSDL was up to date and sane, you'd get a nice client-side API to invoke methods on the remote server.Andrew inherited one such client-side C# API. It looked something like this:
CodeSOD: Time Changes
Dates and times are way more complicated than we usually think they are, especially when we're talking about historical dates and times. The solution, of course, is to always use someone else's work, whether it's a library or your language's built-ins, never implement date handling yourself.For a long time, though, Java's date handling left something to be desired. Which is why Sven found this history lesson in his company's code base:
Error'd: Phoning One In
Many years ago, at the height of the Industrial Revolution, theUnited States was criscrossed by a riot of regional railroads.Gradually, these were acquired or merged until nowthere are only about a half-dozen majornational railroads. In a similar fashion,at the birth of the public Internet, there musthave been thousands of community Internetservice providers. It seemed like every town had its own entrepeneurial enterprise, with some racks of modemsin an office somewhere. Those quickly got snapped upor forced into bankruptcy, as legacy cabletelecoms companies leveraged their existing monopolies into a new line of business. Which brings us to this week's Error'd. Enjoy(?) it.First up,Adrian McCarthy grumbles "Getting help can be difficult when your regional monopolyinternet service provider cannot assemble a functionalweb site. Note that the understandably required Descriptionfield in this online support contact form is disabled."
CodeSOD: Tied to the Train Tracks
Ah, the joys of stringly typed code. Everything can be turned into a string, so why not treat everything as a string? It certainly worked for Sebastian's co-worker, who also took it to another level:
CodeSOD: All in the Timing
We like using constants instead of magic numbers. Today, we see an unusual misuse of them. It's unusual because, while it's a set of bad choices, it's not quite a `#define ONE 1` level of silliness.First, a little background. Benjamin inherited a building automation system. This building automation system was implemented in Microsoft's Visual C++, version 6.0, way back in the 90s. As of the late 2010s, not only was it still in use, it was still pinned to the same compiler version. So not exactly the most modern of applications, but it accomplished the business goals, albeit with a lot of bugs, errors, and mysterious glitches.Here is how the application checked how long an operation took:
CodeSOD: Magical Destruction
Pretty much all object oriented languages have some concept of "destruction": objects need to release any resources they acquired at construction. In a lot of cases, we don't need to customize this terribly much, but when we do, it's vitally important to do it correctly.Nancy's co-worker perhaps didn't understand the "correctly" part. So this was the standard pattern of C++ destructor that they wrote:
Requirements in Technicolor
Managing the requirements for an application is a huge challenge. The hardest part of the challenge is that, very frequently, the user's don't know what they really want or need. Prying it out of them, and giving them an application that actually solves the real problem they have, is an art.The worst situation is when the users are absolutely certain that they do know what they want. This was the situation that Irini found herself in.The project started, as many such projects do, in the wake of a disaster. One of the company's many Capital Improvement Projects (CIP) slipped through the cracks during budgeting. It ran six months past schedule, but managed to close out with a few hundred grand still unspent in its budget. When someone tried to reallocate that money, the management team in charge of managing CIPs found out, they went full code-red, trying to do two things at the same time: understand why that project got lost in tracking, and also why when they tried to reallocate the money, it kept getting reset in their Enterprise Resource Planning (ERP) system.Eventually, that lead them to Sofia, the VP of Finance, and managed them all through a spreadsheet she had created by herself. The ERP kept getting reset because she manually updated it based on the contents of the spreadsheet. The project got lost because she manually color-coded the projects in her spreadsheet, and one day accidentally hid the row, instead of making it yellow.No one liked that there was a manual process. No one liked that only one person ever touched this system. Management wanted a robust, backed-up IT system, and wanted to open the management of this process to more of the finance team, so Sofia wasn't the only failure point.The solution was clear: gather requirements from Sofia and either purchase a product or develop something in house to replace the spreadsheet. Very quickly, it was decided that "develop in house" was the only way to customize the tool to what Sofia's process already looked like, and "standardizing the process" was not an option.Irini was on the IT team that was chosen to build this product. A business analyst tried to sit down with Sofia to suss out her actual requirements, but hit a brick wall. The spreadsheet already did everything she wanted. The spreadsheet was the requirements. She gave the analyst a copy and sent him on his way to get something built.As mentioned, Sofia manually color-coded the rows in the sheet to help with project tracking. Fortunately for the development team, her spreadsheet included a key, describing what the colors meant. Unfortunately, it was this "technicolor yawn", as Irini puts it:Now, as "re-implement this spreadsheet as an application" goes, this isn't terrible. It's an ugly, complicated set of rules, but at least it's documented. But what we have here is a case of one person's idiosyncratic style of organization determining the features for all users of the application.This is what the users said they wanted. This was what the dev team implemented. Everyone on the dev team suggested that maybe they needed a better way of letting users filter, sort, and prioritize their capital projects, possibly even allowing each user to manage custom filters, but no- the spreadsheet was the requirements.When the app launched, the Finance team was excited to have more control over their capital projects. Then they started to use the application, and quickly got confused. It was built, not to solve the problem of managing projects, but to fit Sofia's workflow, and her workflow alone. It was impenetrable and opaque to everyone else. After a few months of endless tickets as users got lost in the confusing interface, most of them gave up.Sofia stuck with it longer, but she hated the application. As it turned out, automatic color coding was a big anti-feature for her, because the rules she had in the sheet were just guidelines, and she wanted to be able to apply any color to any project based on information that existed only in her head.The application is still technically running, but nobody in Finance is using it. They've reverted back to "Sofia has a spreadsheet for it." [Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!
Error'd: Filling
We got quite a few irregular submissions this week from regularcontributors. Which is to say routine contributors. We're not qualified to make judgements about whether or not anyone is whatwhat most folks would call normal.First up,Isaac D. is struggling with localization,kvetching"Apparently this number format is ALIVE and WELL in partsof India and Afghanistan, but us poor Australians on desktopbrowsers also seem to be visually assaulted with it. Iwonder if the Zuck will pay me $1,00,000 for reportingit or do real country borders mean nada in the Metaverse? ;)"This would ordinarily be controlled by some operatingsystem or browser configuration, would it not?
CodeSOD: The Properties of Contract Development
James's management had more work than they had staffing for, so they did what any company would do in that situation: expand their staff. No, of course not, I'm kidding. They bundled up a pile of work and shipped it off to the contractor who gave them the lowest bid, provided absolutely no oversight or code-quality standards in the contract, and hoped for the best.What they got back was a gigantic pile of code that compiled. That is the only positive thing one can say about the code, because it certainly didn't work. Within a few weeks of starting reviewing the gigantic pile of garbage the contractors turned in, the dev team reached the decision that it would be quicker to rewrite from scratch than it was to try and pick apart the trashpile and reshaped the refuse into something approaching their actual requirements.James sends us just one small VB .Net property definition which summarizes the kinds of problems they were dealing with:
CodeSOD: Going to Great Len(gths)
Mira was trawling through some old Python code. This particular block of code needed to load some data from JSON. The data was an array, and the code needed to know how long the array was.Python has a handy len function that does this on anything enumerable. If our developer had used len, we'd be looking at different code today.This was their approach:
CodeSOD: Terning On a Control
One of Tim's co-workers needed to handle a simple condition: if a control in their web app was enabled, show it, otherwise hide it.Now, if you or I were writing that, we might write some awfully verbose code, like:
CodeSOD: A False Comparison
Iterating across a list is a very simple task. It's a CS-101 type thing, and if anything, it's the one thing I'd expect any developer to be able to do without confusing me too much.Brendan has a co-worker that wants to change my mind about this.They write Java code like this:
Error'd: Nothin Doin
IBM Profs was introduced in 1980 including both email and calendaring support. Onlinecalendaring is now old enough to have grandchildren, but we still can't get the simplest things right.As our friendRomeo rhetorically wonders "Million dollar question: What calendar does Microsoft use?"
CodeSOD: Evaluating Selections
If you're writing an application with a drop-down list, it's typical and reasonable to auto-select a certain option in the list. But John found an approach to doing this that's anything but typical.
Tales from the Interview: The Final Interview
Gennifer had a job. Her employer got bought out by another company, and the purchaser was notorious for gobbling up companies, taking over their processes, and then doing mass layoffs. Seeing the writing on the wall, Gennifer started job hunting.Before too long, she had two very likely candidates. The first was Initrode. It wasn't a great match- Gennifer's skills didn't overlap well, and while the salary was respectable, it wasn't as good as the other position, at Initech.Gennifer interviewed at Initrode first. She did a single round of interviews, and left the interview with an offer. She told them that she'd consider it, but also let them know she was engaged in the recruitment process elsewhere. They understood, but did let her know that they would need a response relatively soon.The Initech interviews were wildly different. First, she did an hour and a half interview with the head-hunting agency that connected her with the position. That went well, so the next step was an online coding assessment, which she aced. The final round was a remote interview with Initech, sitting in with Bob, Bob, and Bill."Great to have you on the call," said the first Bob. "Let's just get right into it.""Where do you see yourself in five years?" asked the other Bob.That was a strong opener. What followed were the other typical soft questions: what's your biggest strength, what's your biggest weakness, tell me about a time you had to resolve a conflict, etc.Then Bill got into it. "Pick up an object on your desk," Bill said. "Pick anything."Gennifer picked up an eraser and held it in front of the camera."Okay, now explain multiple inheritance in C++ using that object."Gennifer blinked, surprised. "Um, an eraser has the 'remove marks' functionality. A pencil would have the 'make marks' functionality. Some pencils have erasers on the end, so those pencils are also erasers, so we could say that they inherit from both the regular pencil class and the eraser class."Bill shook his head. "That isn't really the best example."Gennifer put the eraser down."How about this," the other Bob said. "How would you test a coffee mug?"Gennifer thought that was a better question for an engineer at Pfaltzgraff or a similar company, but she described a series of tests, starting with basic functionality (I can lift it by the handle, I can pour liquid into it) to more stress testing type considerations. That answer they liked."What I need you to tell me," Bill said, "is why I should hire you?""I mean, you're actively looking for developers, my skills are a perfect match for the position. That seems like a good reason to hire someone."Bill shook his head. "What I need to know is that you're not going to take this job and leave after several months."The Bobs nodded. One of them said, "We've had a little problem with retention, lately.""We think it's millennials," the other said. "They can't really commit to a hard day's work.""They just take the job, discover they don't like it here, and leave.""How do we know you're not going to do that to us, too?" Bill asked.That exchange raised so many red flags that it could have collapsed the USSR all over again. Gennifer replied with a statement about how her job history showed that she tended to stick it out in jobs, and wasn't simply running from job to job as a form of career advancement. They concluded the interview."Someone from our office will be in touch in the next two weeks with feedback," the Bobs said.Gennifer left the interview sure of two things: they didn't want to hire her, and she didn't want to work there. So she wrote up an email, thanking them for their time, but she was going to move forward with a different opportunity. She sent it off and thought that was the end of that.The headhunter called a few minutes after she hit send. "What are you doing? You can't decline this offer.""They haven't made an offer," Gennifer said, "and I don't think they're going to.""Are you kidding? I just got off the phone, and they were raving about you. They think you're great. They definitely want to move forward. They just have a hard interviewing style, everyone walks out thinking they whiffed it. The job is yours.""Well, I don't think I'm interested.""Oh, so you're wasting my time, then?" the recruiter said, angrily."No- it's just-"Gennifer didn't want to burn a bridge with the headhunter- in her locale, it was a small industry and everyone knew everyone- so she politely let him rant for nearly an hour about how great the opportunity was, how much Initech wanted her on their team, and how absolutely rude it would be if she didn't take the position. She'd be wasting everyone's time."I apologize for my rudeness," she said, "but I have to do what's best for my career. And honestly, if that's their normal interview process, and this is their normal communication style, I don't want to work there. Thank you for your time."Gennifer now works with Initrode. The headhunter still sends her messages on LinkedIn, suggesting she should reconsider. [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
CodeSOD: Trying Parses
Another day, another terrible way to validate integers. Today's submission comes from Sluiper.This approach, at least, contains a mild bit of cleverness. It's not the good kind of cleverness that makes a complicated problem more clear and easier to understand, but the bad kind that exploits assumptions about low-level technical details.
CodeSOD: An Array of Colors
Sandra, still at InitAg, has to work with Brad. Some time ago, Brad was assigned a slew of front-end development tasks, since he's a web developer. But Brad isn't a front-end developer, and doesn't really have a good grasp of front-end development. Management isn't clear on the difference: "Aren't you a web developer? I don't care which end you use, just develop." Brad is also game to tackle whatever task is assigned to him, regardless of whether he has any sense of how to solve the problem.When Brad needed to display data on a map, the requirements wanted the map layers to be distinguished by color. So Brad did the usual thing one might do in this situation: he created a gigantic array of all possible colors that might be used on the map. Actually, he created two: colors and colorsBlackWhite.
Error'd: It Seats Zero
Automotive afficionado Mike S. proudly relates "My first and only car has been a classic 1965 6-cyl FordNull. I've always loved it but it does crash from timeto time, even though I've received many pointers on howto avoid that. I've considered getting an Infiniti andthen would divide my time between the two." Avoid pointers,Mike.
CodeSOD: Peer Feedback
Pieter-Jan needed to add some features to a PHP-based site for managing student assessments. Students would complete projects, submit them, and then receive feedback from their peers. The number of peers providing feedback is variable, so the application has to manage that. Which, you might be thinking, "that sounds like not a big deal to manage," but for Pieter-Jan's predecessor, it seems like it may have been.
CodeSOD: Evaluating Regexes
Stack V supports a web application that accepts regexes from users. For legacy reasons, the users must supply the surrounding / characters, as well. There was some validation to ensure that the inputs were correct, but QA discovered that invalid regular expressions were getting through.They filed a bug, it got triaged, and then shipped off to a contractor to patch. This was the contractor's solution:
CodeSOD: Exhaustive Scheduling Options
A true confession: I absolutely cannot successfully edit a crontab file without spending a lot of time reading docs on what all the little date/time/interval flags mean. Partially, it's just that I don't do it very often, but mainly the information flies right out of my head once I've done it. I can absolutely understand why someone might want to write a little helper program to help themselves manage their crontab.I just can't understand why they'd write this one, sent to us Beorn. We'll have to take this one in chunks, because it's 18,905 lines.We'll start with the function dayofweek, so you can get a sense of the pattern that gets used. Here's the first if condition for its core logic:
CodeSOD: Terning Nulls into Values
A former co-worker of David S wanted to check for nulls, and apparently, they had just learned about the ternary operator, so they wanted to combine these actions. That, itself, isn't a WTF- using ternaries to coalesce nulls is a time-honored tradition and generally pretty effective.Let's see how this Java developer approached it:
CodeSOD: Tenrning Nulls into Values
A former co-worker of David S wanted to check for nulls, and apparently, they had just learned about the ternary operator, so they wanted to combine these actions. That, itself, isn't a WTF- using ternaries to coalesce nulls is a time-honored tradition and generally pretty effective.Let's see how this Java developer approached it:
Error'd: Take Off
Slow news week at Error'd, so we're dusting off a couple of submissions from earlier. That last one's a beauty, eh?Special Dave flexes"Got my annual request for a donation to Habitat forHumanity. Not sure if their new URL is meant to conveyjust how special I am as a donor, or if someone wasgoofing off with a test for formatting the form andforgot to change before their production run." We loveyou too, sweet cheeks.
CodeSOD: The Duff Code
As we frequently note, a staggering number of real-world software products start their lives as Access databases running from a shared folder somewhere. There are professional developers who end up maintaining these monstrosities.Gregory has had the misfortune of being one of those developers. A client has a terribly performing Access database, and it happens to be the driver of their business: it generates insurance quotes for an insurance company.Let's take a look at some of the code.
...567891011121314...