OR 

CodeSOD: Production Comments

A fair bit of bad code requires at least a passing understanding of the language in question, or the domain involved. But bad comments transcend programming languages. Vilx sends us this one, which comes from code which is definitely running in production. // WARNING!!! Special case for [external API] testing. // DO NOT LET THIS PIECE OF CODE FIND ITS WAY TO PRODUCTION Adding more commentary almost feels like gilding the lilly. Almost. One of th

favicon of http://thedailywtf.com

Error‘d: Not So Smart After All!

Today I learned that the time between 12 PM and 1 PM is 12:28 noon according to CNN, Drew W. writes. Robert L. wrote, The Trump campaign website is a little bit confused as to when election day is. I changed over to playing on my Nintendo Switch from watching Netflix on my so-called smart TV and apparently, the subtitles didnt get the message, writes Josh. You know how after watching a really scary horror movie, bumps in the night can leave

favicon of http://thedailywtf.com

CodeSOD: The Default Value

Cicely (previously) returned to the codebase which was providing annoyances last time. This time, the code is meant for constructing objects based on a URL pattern. Specifically, the URL might have a format like api/resource/{id}. Looking at one of the constructors, though, it didn‘t want an ID, it wanted an array of them. Cicely wasn‘t passing multiple IDs off the URL, and wasn‘t clear, from the documentation, how it worked, h

favicon of http://thedailywtf.com

Big Iron

Skill which you don‘t use regularly can get rusty. It might not take too much to get the rust off, and remind yourself of what you‘re supposed to be doing, but the process of remembering what you‘re supposed to do can get a little damaging. Lesli spent a big chunk of her career doing IT for an insurance company. They were a conservative company in a conservative industry, which meant they were still rolling out new mainframes i

favicon of http://thedailywtf.com

CodeSOD: Pixel Perfect Design

Octavia (previously) didnt just inherit a C# application with dodgy approaches to string handling. Its also an application with questionable understandings of CSS. CSS is far from perfect, and offers a lot of pitfalls and traps. Theres a reason the impossibility of vertically centering text is a punchline. Its so flexibly declarative that, in many cases, there are many ways to achieve the same styling result, and its difficult to pick out the co

favicon of http://thedailywtf.com

CodeSOD: Frist Item

In .NET, if you want to get the first item from an IList object, you could just use the index: list[0]. You also have a handy-dandy function called First, or even better FirstOrDefault. FirstOrDefault helpfully doesn‘t throw an exception if the list is empty (though depending on what‘s in the list, it may give you a null). What I‘m saying is that there are plenty of easy, and obvious ways to get the first element of a list. St

favicon of http://thedailywtf.com

CodeSOD: Testing Architectures

Marlyn‘s employer ships software for a wide variety of CPU architectures. And depending on which branch of the product you were digging into, you might have code that builds for just i386, x86_64, PPC, and PPC64, while another branch might add s390, s390x, and aarch64. As you might imagine, they have a huge automated test suite, meant to ensure that changes don‘t break functionality or compatibility. So it‘s a pity that their t

favicon of http://thedailywtf.com

CodeSOD: Mod-El Code

Long-lived projects can have interesting little corners. Choices made 13 years ago can stick around, either because they work well enough, or because, well, every change breaks somebodys workflow. Todays anonymous submitter was poking around the code base of a large, long-lived JavaScript framework. In a file, not modified since 2007, but still included in the product, they found this function. .comment { border: none; } _getAdjustedDay: function

favicon of http://thedailywtf.com

CodeSOD: When All You Have Is .Sort, Every Problem Looks Like a List(of String)

When it comes to backwards compatibility, Microsoft is one of those vendors that really commits to it. It‘s not that they won‘t make breaking changes once in awhile, but they recognize that they need to be cautious about it, and give customers a long window to transition. This was true back when Microsoft made it clear that .NET was the future, and that COM was going away. To make the transition easier, they created a COM Interop sys

favicon of http://thedailywtf.com

CodeSOD: Tranposing the Key

Russell F sends us this C# fuction, and I have to be honest: I have no idea what its supposed to do. I can trace through the logic, I can see what it does, but I dont understand why it does it. private ListLaborService Tranpose(ListLaborService laborService) { int half = (int)Math.Ceiling((decimal)(laborService.Count)/2); for (int i = 0; i laborService.Count; i++) { if (i half) laborService[i].Order = 2 * i;

favicon of http://thedailywtf.com

CodeSOD: Unset-tled

Alleen started by digging into a PHP method which was just annoying. _find_shipment_by_object_id would, when it couldnt find the ID, return false, instead of the more expected null. Not terrible, but annoying. Worse, it didnt return the shipment eihter, just a key which could be used to fetch a shipment from an array. Again, all thats just annoying. It was when looking at the delete_shipment method that Alleen had the facepalm moment. public

favicon of http://thedailywtf.com

Announcements: What the Fun Holiday Activity?

Time just flies right past, and before you know it, the holidays will be here. Which is why you had better hurry up and try your hand at giving us the best WTF Christmas Story ever, to help us found a new holiday tradition. Or at least, give us one bright spot in the yawning abyss of 2020. Can you teach us the true meaning of WTFMas? ul { list-style: circle; } What We Want We want your best holiday story. Any holiday is valid, though g

favicon of http://thedailywtf.com

CodeSOD: Utility Functions

As a personal perspective, I dont tend to believe that mastery of a programming tool is nearly as important as mastery of the codebase and problem domain youre working on. But there are some developers who just dont want to learn the codebase or what other developers are doing. Take Jessicas latest co-worker, which is similar to some previous co-workers. In this case, there was a project in flight that was starting to fall behind schedule. Manag

favicon of http://thedailywtf.com

Error‘d: Reduced Complexity, Increased Errors

I tried a more complex password and got the same error message, but after trying with a shorter password, it let me through! wrote Sameer K. Lucas T. writes, Translation: Dear ladies and gentlemen, because of an internet failure (some identifying info here), the electronic signature and the owl are unavailable. The issue is being worked on. Kind regards, your application support. Well, isnt this just great. How exactly am I supposed to work wit

favicon of http://thedailywtf.com

CodeSOD: Prepend Eternal

Octavia inherited a decade old pile of C#, and the code quality was pretty much what one would expect from a decade old pile that hadnt seen any real refactoring: nothing but spaghetti. Worse, it also had an inner platform problem, as everything they put in their API could conceivably be called by their customers own customizations. One small block caught her eye, as suspicious: .comment { border: none } public void SomeFunctionality { // Other

favicon of http://thedailywtf.com

Error‘d: Hate the Error and Hate the Game

Somehow, a busy day for Blizzards servers is going to last for around 6 months, writes James G. So, is interpreting error messages a sport now? Jay C. wrote. Drew W. writes, Im not sure how, but Sparkpost thinks Ive had over 130 emials opened for every one Ive sent! I...may have a problem staying off of my phone, Kevin V. writes. Gordon wrote, Kind of sums up the 2020 season, doesnt it? [Advertisement] Utilize BuildMaster to release

favicon of http://thedailywtf.com