Feed the-daily-wtf The Daily WTF

Favorite IconThe Daily WTF

Link http://thedailywtf.com/
Feed http://syndication.thedailywtf.com/TheDailyWtf
Updated 2024-03-28 21:31
CodeSOD: Sorts of Dates
We've seen loads of bad date handling, but as always, there's new ways to be surprised by the bizarre inventions people come up with. Today, Tim sends us some bad date sorting, in PHP.
CodeSOD: Never Retire
We all know that 2038 is going to be a big year. In a mere 14 years, a bunch of devices are going to have problems.Less known is the Y2030 problem, which is what Ventsislav fighting to protect us from.
CodeSOD: Exceptional String Comparisons
As a general rule, I will actually prefer code that is verbose and clear over code that is concise but makes me think. I really don't like to think if I don't have to.Of course, there's the class of WTF code that is verbose, unclear and also really bad, which Thomas sends us today:
CodeSOD: Contains a Substring
One of the perks of open source software is that it means that large companies can and will patch it for their needs. Which means we can see what a particular large electronics vendor did with a video player application.For example, they needed to see if the URL pointed to a stream protected by WideVine, Vudu, or Netflix. They can do this by checking if the filename contains a certain substring. Let's see how they accomplished this...
Error'd: You Can Say That Again!
In a first for me, this week we got FIVE unique submissionsof the exact same bug on LinkedIn. In the spirit of the theme,I dug up a couple of unused submissions of older problems atLinkedIn as well. I guess there are more than the usual numberof tech people looking for jobs.John S., Chris K., Peter C., Brett Nash and Piotr K. all sent in samples of this doublebug. It's a flubstitution AND bad math,together!
CodeSOD: Reading is a Safe Operation
Alex saw, in the company's codebase, a method called recursive_readdir. It had no comments, but the name seemed pretty clear: it would read directories recursively, presumably enumerating their contents.Fortunately for Alex, they checked the code before blindly calling the method.
CodeSOD: Do you like this page? Check [Yes] or [No]
In the far-off era of the late-90s, Jens worked for a small software shop that built tools for enterprise customers. It was a small shop, and most of the projects were fairly small- usually enough for one developer to see through to completion.A co-worker built a VB4 (the latest version available) tool that interfaced with an Oracle database. That co-worker quit, and that meant this tool was Jens's job. The fact that Jens had never touched Visual Basic before meant nothing.With the original developer gone, Jens had to go back to the customer for some knowledge transfer. "Walk me through how you use the application?""The main thing we do is print reports," the user said. They navigated through a few screens worth of menus to the report, and got a preview of it. It was a simple report with five records displayed on each page. The user hit "Print", and then a dialog box appeared: "Print Page 1? [Yes] [No]". The user clicked "Yes". "Print Page 2? [Yes] [No]". The user started clicking "no", since the demo had been done and there was no reason to burn through a bunch of printer paper."Wait, is this how this works?" Jens asked, not believing his eyes."Yes, it's great because we can decide which pages we want to print," the user said."Print Page 57? [Yes] [No]".With each page, the dialog box took longer and longer to appear, the program apparently bogging down.Now, the code is long lost, and Jens quickly forgot everything they learned about VB4 once this project was over (fair), so instead of a pure code sample, we have here a little pseudocode to demonstrate the flow:
CodeSOD: A Debug Log
One would imagine that logging has been largely solved at this point. Simple tasks, like, "Only print this message when we're in debug mode," seem like obvious, well-understood features for any logging library."LostLozz offers us a... different approach to this problem.
CodeSOD: How About Next Month
Dave's codebase used to have this function in it:
Error'd: Can't Be Beat
Date problems continue again this week as usual, both sublime (Goodreads!) and mundane(a little light time travel). If you want to be frist poster today, you're going to reallyneed that time machine.Early BirdDave crowed "Think you're hot for posting the first comment? I posted the zeroth reply to this comment!"You got the worm, Dave.
CodeSOD: Query the Contract Status
Rui recently pulled an all-nighter on a new contract. The underlying system is... complicated. There's a PHP front end, which also talks directly to the database, as well as a Java backend, which also talks to point-of-sale terminals. The high-level architecture is a bit of a mess.The actual code architecture is also a mess.For example, this code lives in the Java portion.
Check Your Email
Branon's boss, Steve, came storming into his cube. From the look of panic on his face, it was clear that this was a full hair-on-fire emergency."Did we change anything this weekend?""No," Branon said. "We never deploy on a weekend.""Well, something must have changed?!"After a few rounds of this, Steve's panic wore off and he explained a bit more clearly. Every night, their application was supposed to generate a set of nightly reports and emailed them out. These reports went to a number of people in the company, up to and including the CEO. Come Monday morning, the CEO checked his inbox and horror of horror- there was no report!"And going back through people's inboxes, this seems like it's been a problem for months- nobody seems to have received one for months.""Why are they just noticing now?" Branon asked."That's really not the problem here. Can you investigate why the emails aren't going out?"Branon put aside his concerns, and agreed to dig through and debug the problem. Given that it involved sending emails, Branon was ready to spend a long time trying to debug whatever was going wrong in the chain. Instead, finding the problem only took about two minutes, and most of that was spent getting coffee.
CodeSOD: Wait for the End
Donald was cutting a swathe through a jungle of old Java code, when he found this:
CodeSOD: Some Original Code
FreeBSDGuy sends us a VB .Net snippet, which layers on a series of mistakes:
Error'd: Time for more leap'd years
Inability to properly program dates continued to afflictvarious websites last week, even though the leap day itself had passed.Maybe we need a new programming language in which it'simpossible to forget about timezones, leap years, or Thursday.Timeless Thomas subtweeted "I'm sure there's a great date-related WTF story behind this tweet"Gosh, I can't imagine what error this could be referring to.
CodeSOD: A Bit of a Confession
Today, John sends us a confession. This is his code, which was built to handle ISO 8583 messages. As we'll see from some later comments, John knows this is bad.The ISO 8583 format is used mostly in financial transaction processing, frequently to talk to ATMs, but is likely to show up somewhere in any transaction you do that isn't pure cash.One of the things the format can support is bitmaps- not the image format, but the "stuff flags into an integer" format. John wrote his own version of this, in C#. It's a long class, so I'm just going to focus on the highlights.
Representative Line: A String of Null Thinking
Today's submitter identifies themselves as pleaseKillMe, which hey, c'mon buddy. Things aren't that bad. Besides, you shouldn't let the bad code you inherit drive you to depression- it should drive you to revenge.Today's simple representative line is one that we share because it's not just representative of our submitter's code base, but one that shows up surprisingly often.
CodeSOD: Moving in a Flash
It's a nearly universal experience that the era of our youth and early adulthood is where we latch on to for nostalgia. In our 40s, the music we listened to in our 20s is the high point of culture. The movies we watched represent when cinema was good, and everything today sucks.And, based on the sheer passage of calendar time, we have a generation of adults whose nostalgia has latched onto Flash. I've seen many a thinkpiece lately, waxing rhapsodic about the Flash era of the web. I'd hesitate to project a broad cultural trend from that, but we're roughly about the right time in the technology cycle that I'd expect people to start getting real nostalgic for Flash. And I'll be honest: Flash enabled some interesting projects.Of course, Flash also gave us Flex, and I'm one of the few people old enough to remember when Oracle tried to put their documentation into a Flex based site from which you could not copy and paste. That only lasted a few months, thankfully, but as someone who was heavily in the Oracle ecosystem at the time, it was a terrible few months.In any case, long ago, CW inherited a Flash-based application. Now, Flash, like every UI technology, has a concept of "containers"- if you put a bunch of UI widgets inside a container, their positions (default) to being relative to the container. Move the container, and all the contents move too. I think we all find this behavior pretty obvious.CW's co-worker did not. Here's how they handled moving a bunch of related objects around:
CodeSOD: Classical Architecture
In the great olden times, when Classic ASP was just ASP, there were a surprising number of intranet applications built in it. Since ASP code ran on the server, you frequently needed JavaScript to run on the client side, and so many applications would mix the two- generating JavaScript from ASP. This lead to a lot of home-grown frameworks that were wobbly at best.Years ago, Melinda inherited one such application from a 3rd party supplier.
Error'd: Once In A Lifetime
Not exactly once, I sincerely hope. That would be tragic."Apparently, today's leap day is causing a denial of serviceerror being able to log into our Cemetery Management softwaredue to some bad date calculations," writes Steve D. To be fair, he points out, it doesn't happen often.
CodeSOD: A Few Updates
Brian was working on landing a contract with a European news agency. Said agency had a large number of intranet applications of varying complexity, all built to support the news business.Now, they understood that, as a news agency, they had no real internal corporate knowledge of good software development practices, so they did what came naturally: they hired a self-proclaimed "code guru" to built the system.Said code guru was notoriously explosive. When users came to him with complaints like "your system lost all the research I've been gathering for the past three months!" the guru would shout about how users were doing it wrong, couldn't be trusted to handle the most basic tasks, and "wiping your ass isn't part of my job description."With a stellar personality like that, what was his PHP code like?
CodeSOD: You Need an Alert
Gabe enjoys it when clients request that he does updates on old software. For Gabe, it's exciting: you never know what you'll discover.
CodeSOD: A Split Purpose
Let's say you had input in the form of field=value, and you wanted to pick that "value" part off. In C#, you'd likely just use String.Split and call it a day. But you're not RK's co-worker.
CodeSOD: Climbing Optimization Mountain
"Personal Mountains" was hearing dire rumors about one of the other developers; rumors about both the quality of their work and their future prospects at the company. Fortunately for Personal Mountains, they never actually had to work with this person.Unfortunately, that person was fired and 30,000 lines of code were now Personal Mountains' responsibility.Fortunately, it's not really 30,000 lines of code.
Error'd: Hard Daze Night
It was an extraordinarily busy week at Error'd HQ.The submission list had an all-time record influx, enough for a couple of special edition columns. Among the list was an unusual PEBKAC. We don't get many ofthese so it made me chuckle and that's really all it takes to get a submission into the mix.Headliner Lucio Crusca perseverated "Here's what I found this morning, after late night workingyesterday, sitting on my couch, with my Thinkpad on my lap.No, it was not my Debian who error'd. I'm afraid it was me."
CodeSOD: The Default Path
I've had the misfortune to inherit a VB .Net project which started life as a VB6 project, but changed halfway through. Such projects are at best confused, mixing idioms of VB6's not-quite object oriented programming with .NET's more modern OO paradigms, plus all the chaos that a mid-project lanugage change entails. Honestly, one of the worst choices Microsoft ever made (and they have made a lot of bad choices) was trying to pretend that VB6 could easily transition into VB .Net. It was a lie that too many managers fell for, and too many developers had to try and make true.Maurice inherited one of these projects. Even worse, the project started in a municipal IT department then was handed of to a large consulting company. Said consulting company then subcontracted the work out to the lowest bidder, who also subcontracted out to an even lower bidder. Things spiraled out of control, and the resulting project had 5,188 GOTO statements in 1321 code files. None of the code used Option Explicit (which requires you to define variables before you use them), or Option Strict (which causes errors when you misuse implicit data-type conversions). In lieu of any error handling, it just pops up message boxes when things go wrong.
CodeSOD: Route to Success
Imagine you're building a PHP web application, and you need to display different forms on different pages. Now, for most of us, we'd likely be using some framework to solve this problem, but even if we weren't, the obvious solution of "use a different PHP file for each screen" is a fairly obvious solution.Dare I say, too obvious a solution?What if we could have one page handle requests for many different URLs? Think of the convenience of having ONE file to run your entire application? Think of the ifs.
CodeSOD: Merge the Files
XML is, arguably, an overspecified language. Every aspect of XML has a standard to interact with it or transform it or manipulate it, and that standard is also defined in XML. Each specification related to XML fits together into a soup that does all the things and solves every problem you could possibly have.Though Owe had a problem that didn't quite map to the XML specification(s). Specifically, he needed to parse absolutely broken XML files.
Representative Line: From a String Builder
Inheritance is one of those object-oriented concepts that creates a lot of conflicts. You'll hear people debating what constitutes an "is-a" versus a "has-a" relationship, you'll hear "favor composition over inheritance", you'll see languages adopt mix-in patterns which use inheritance to do composition. Used well, the feature can make your code cleaner to read and easier to maintain. Used poorly, it's a way to get your polymorphism with a side of spaghetti code.Greg was working on a medical data application's front end. This representative line shows how they use inheritance:
Error'd: Mirror mirror
An abstitution, an assortment, time travel, bad language, and an error'd.First up,Jeremy Pereira pushes the boundaries of this column by sharing something right."Sort of an anti-WTF. It took them 44 minutes to realise they'd made a boo-boo."They probably were notified, but it's still pretty goodtime to repair. Especially considering the issues we knowof that last for years and years.
CodeSOD: While Nothing
Jose received a bit of VB .Net UI code that left him scratching his head.
A Stalled Upgrade
It was time to start developing version 2 of Initech's flagship software product. This meant planning meetings. So many planning meetings.The most important one, for the actual development team, was the user story meeting. The core of these meetings was a few folks from the programming team, including Steve, the director of architecture, Brian, and a variety of product owners, responsible for different segments of the overall product.As a group, they'd review the user stories, and approve them. Once they were approved for development, work would begin.The meetings were difficult to schedule, because of the number of stakeholders, and they were viewed as a checkpoint- you can't start implementing features until the product owner has walked through the user story with the team, but they were also a priority.At the meeting, product owner Renee started walking the team through some of the features she owned. "So, here's my user, Fred Flinstone." Her slide popped up an image of the animated character next to a set of bullet points describing the feature. "He needs to add an item into inventory, so that it can actually be sold. To do that..."Renee walked them through the details of the feature. Heads nodded around the table- it was a pretty straightforward CRUD application. It was good that the product owner walked them through a few workflow things unique to Initech's product, but there wasn't anything particularly shocking.Renee advanced to the next slide. "And now, Fred needs to run a report. This report needs to..."Again, Renee walked them through the key fields that needed to be on the report, how the report was triggered, what the reasonable filtering options would be."Any questions?"Brian, the director, looked thoughtful for a moment, and then said, "I think I do. I can't really see a reason why one person would want to both add items to inventory- a receiving job- and run reports on inventory consumption. There's no reason someone doing the task would also need to run the report. I can't accept your user stories until you change one of the users to be a different person.""What? The name doesn't matter," Renee protested."We should probably just stick a pin in this and pick up when we can reschedule another meeting. Thank you everyone," Brian said. He grabbed his laptop, stood, and left the meeting. Everyone sat there for a moment, realized the meeting was actually over, and followed him out a few minutes later.That afternoon, Steve finally managed to find Brian. "What the heck was that?"Brian sighed. "Look, the entire development team is swamped, you know it. We don't have bandwidth to take on new work. Tracey should have that priority-one bug done in a few days, and maybe once that's done we can start putting resources on the the version 2 project. For now, we need to stall, and that was the only thing I could think of." [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Representative Line: A Memory of Strings
As we saw yesterday, padding can be hard.Jasmine received a set of tickets all complaining that the file download portion of an ASP .Net application took too long. Users frequently had to wait for up to 15 minutes before their browser finished downloading the output of the web application.This particular module generated the file by doing a set of Response.Writes to build the file as part of the HTTP response. This particular line ran 200,000 times in the process of creating the file:
CodeSOD: Timestamped File Name
It's been a minute since some bad date handling code. Wesley inherited this C# blob which exists to generate timestamped filenames.
Error'd: ROUS
I don't think they exist.ChoosyChris P. wants more choices, carping "You keep using that word, I don't think it means what you think it means."
A Bit About the HP3000
Today's anonymously submitted story is a case where the WTF isn't the code itself, per se. This arguably could be a CodeSOD, and we'll get to the code, but there's so much more to the story.Our submitter, let's call them Janice, used to work for a financial institution with a slew of legacy systems. One such system was an HP3000 minicomputer. "Mini", of course, meant "refrigerator sized".The HP3000 itself is an interesting, if peripheral story, because it's one of the tales of a product launch going incredibly wrong. Let's talk a little history.We start with the HP2100 in 1966, which Hewlett Packard did nothing to design, and instead purchased the company that designed it. The core innovation of the HP2100 was that it was architecturally similar to a PDP-8, but supported full 16-bit memory, instead of PDP's 12-bit.HP didn't really know what they had bought- they marketed it as a "test and instrumentation" system, and were surprised when businesses purchased it for back office operations. They ended up with one of the most popular minicomputers for office use, despite it not being designed for that purpose.Thus began the projects "Alpha" and "Omega". Alpha was a hardware refresh of the 2100, with a better memory model. Omega was a ground-up redesign for 32-bit memory, which would allow it to support a whopping 4MB of RAM. There was just one problem with the Omega design: they didn't have funding to actually finish it. The project was killed in 1970, which threw some of the staff into "wear black armbands to work" levels of mourning.Unfortunately, while work was done on Omega, the scope of Alpha crept, which resulted in another project management wasn't sure could be delivered. But the market was there for a time-sharing minicomputer, so they pressed on despite the concerns.The HP2000-line had time sharing system that used multiple processors. There was a front-end processor which handled user interactions. Then there was the actual CPU, which ran programs. This meant that time-sharing was simplified- the CPU just ran programs in a round-robin fashion, and didn't have to worry about pesky things like user inputs. Essentially, it was really just a batch processing system with a multi-user front-end.The designers of Alpha wanted to support full multiprogramming, instead of this hybrid-ish model. But they also needed to support traditional batch processing, as well as real-time execution. So the team split up to build the components of the "Multi-Programming Executive" module, which would allow all of these features.The Alpha, which was still 16-bit, didn't have the luxurious 4MB of RAM- it had 128kB. The MPE used much more memory than 128kB. This led to a massive crunch as the programmers worked to shrink MPE into something usable, while marketing looked at the deadlines and said, "We were supposed to be selling this thing months ago!"The result was a massive war between engineering and marketing, where marketing gave customers promises about what the performance would be, engineering told marketing what the actual performance would be (significantly worse than what marketing was promising), and then management would demand engineering "prove" that marketing's over-promises could be met.The initial ship-date was November, 1972, and by god, they shipped on time. Nothing actually worked, but they shipped. The first computer out the door was returned almost immediately. It could only handle two simultaneous users before slowing to a crawl, and crashed every ten minutes. By December, HP had gotten that to "crashes every two hours". They kept shipping machines even as they had to cut features and reliability promises.Those frequent crashes also concealed another bug: after running for 24 days, the HP3000's clock would overflow (2^31 milliseconds) and the clock would magically reverse by 25 days. As one sysop of a purchased HP3000 put it: "The original designers of MPE never thought the OS would stay up for 25+ days in a row".After a bunch of management shuffling, the titular Packard of Hewlett Packard sent a memo: production was stopping and all sold computers were being recalled. Customers were offered HP2000s in its place, or they could wait until fall 1973 for a revised version- that would only support 4-6 users, far fewer than marketing's initial promises of 64. This pleased no one, and it's reported that some customers cried over the disappointment.With sales paused, the entire computer underwent a design overhaul. The resulting machine was faster and cheaper and could actually handle 8 simultaneous users. One year after the botched launch, the HP3000 went back on the market, and ended up being a full success.It was so successful, HP continued supporting the HP3000 until 2010, which is where Janice enters our story. Circa 2006, she needed to update some Pascal code. That code used a lot of bit-masks to handle flags, which is normally a pretty easy function in Pascal- the language has a standard set of bitwise operations. So Janice was surprised to see:
CodeSOD: Return Country
Let's say you have a database table containing a list of countries. Given the primary key of a country in that table- an arbitrary ID field- you need to look up the name of that country.Curtis's predecessor dropped this solution:
CodeSOD: Max Character Width
One of the "features" of the Oracle database is that, in addition to the "wonderful" PL/SQL language for building stored procedures, you can also write stored procedures in Java.Now, the skills of "being a good database programmer" and "being a good Java programmer" are not necessarily overlapping, especially when you're deep in the world of Oracle's approach to programming. Which is where this submission, from Tomas comes from.
A Laboratory Upgrade
Unfortunately for Elena, the laboratory information management system (LIMS) her team used was being sunsetted by the vendor, Initech. She's a biochemist working in a pathology department, and this software is vital to tracking the tests need, the tests already run, and providing critical notifications about abnormal test results.Since Initech was sunsetting that product, the hospital system put out an RFQ for a replacements, and after a multi-year bidding process, offered the contract for replacing the software to Initech.And thus, IniLab went away, and was replaced by IniHeal. Gone was the classic terminal interface that everyone had learned to use, and in its place was a "user friendly" GUI- a GUI that buried functionality behind fifteen clicks, had no meaningful keyboard shortcuts, and was constantly changing as they pushed updates, making it impossible to adjust to.Also gone was the IniLab scripting language. IniLab's scripting language was how they had assembled workflows for laboratory processes. You could have fine grained control of which scripts tied to which kinds of tests, and even build custom workflows as one-offs, if necessary. They had many thousands of lines of code that needed to be ported over into IniHeal. The problem was IniHeal's approach to scripting was... well, bad.First, IniHeal doesn't allow you write scripts. Instead, it has a pair of "rule" files. The marketing copy calls these "declarative", and promises that they're an upgrade. In practice, these are gigantic files that contain a set of rules that are evaluated for every test and every sample.But the worse problem in IniHeal is how it lets you handle data. In IniLab, if you wanted the patient's age, you might reference the field by name: Patient.age. In IniLab, you need to use the PPPPLL. What is the PPPPLL?PPPPLL stands for "position" and "length". Instead of referencing a field by name, you have to reference the field by its byte offset and length. So Patient.age might be [091001]. And no, there's no easy way to create constants or variables to hold your PPPPLLs, you just have to know that [091001] is age, and hope that the input data never changes its layout.Now, one of the things Elena noticed while techs were on-site is that the length of the date time fields was 32 bits, and the data was seconds since the Unix epoch. So she asked one of the senior developers "Hey, is this software Year 2038 safe?"The developer laughed. "I'll be retired by then."The final insult to injury is that this software wasn't installed on any laboratory workstations. Instead, they had to use Remote Desktop to access it inside of a VM. While the environment was theoretically locked down so that the only program you could run was IniHeal, in practice it was trivially easy to get to a desktop inside the VM.Curious, Elena poked around. She not only found the installation logs from her lab's deployment, but the installation logs from several other labs. These logs included various internal and private details, including account passwords. Somehow, log files from client installs had ended up in their installation media and were deployed to every client site.Elena reported the potential data breach. The final finding was that the password in question was long defunct, which led management to decide "well, that's no problem then."IniHeal has a slogan about equipping customers with innovative tools, but Elena proposes a new one:"The Q in IniHeal is for Quality." [Advertisement] ProGet's got you covered with security and access controls on your NuGet feeds. Learn more.
Error'd: Groundhog Day
In this week's episode we have some moreadventures in shipping and misadventures with dates.I justasked "Hey Google, how many days are therein February THIS year" and they answered confidently "28 days."I briefly considered autoplaying that query on this page to seehow many of your devices would answer correctly, but then Idecided I should autoplay a command to order me a pizza andthen I thought better of the whole thing.Following up on an earlier submission,Dave P. reports"Much to my amazement, the package did arrive in time for Christmas, but just barely. USPS really came through on their end, taking less than 2 days to deliver the package,after the original delivery service took 12 days to find the USPS dropoff facility."Hah! Somebody owes me a nickel!
CodeSOD: A Well Known Address
Amanda's company wanted to restrict access to a service by filtering on the requestor's IP address. Yes, this is a terrible idea. So they wanted to make it a bit smarter, and also filter on various subnets. But they had a LOT of different subnets.So the result was this:
CodeSOD: A Voice Map
Let's say your company wanted to offer special deals. When a customer calls about one of these deals, you want to play an automated customer support message using SignalWire, a tool for scripting phone voice trees.This is a natural case for using a Map data structure. Which is what Ajay's predecessor did. They just... uh... weren't sure how to use a Map.
CodeSOD: 2019 Was a Fine Year
Efren's employer recently acquired a competitor. The competitor had been struggling for a number of years, and the acquisition was a last ditch attempt to preserve at least some of the business (a complete closure was the only other option).Now, "struggling for a number of years" sounds fairly vague, but due to some bad database design, we actually have a clear indicator of exactly when the company gave up:
CodeSOD: Bent Struts
Luke has inherited a Java Struts-based application. Struts is one of the many Java web frameworks, designed around having HTTP requests trigger actions- that is routing HTTP requests to a specific function call.Now, on one screen, the user filled in a form, and then the corresponding action on the server side needed to read the form data for an eventId and act upon it. In Struts, this can be very simple:
Error'd: Ride Ride Ride
File under "Old Business": Swissrail just can't catch a break.Diligent Richard B. dug into the news and reports"After following the link from this week's Error'd, I cameacross this interesting description in Swissrail's Member list.The filename means 'Company description En(glish)'.They have the same thing in French; the German description is normal."
CodeSOD: Control Tree
User interfaces tend to map fairly naturally to trees as a data structure. In the modern world where we've forgotten how to make native UIs and do everything as web applications pretending to be native, the "tree" model is explicit via the DOM. But even in native UIs, we tend to group controls into containers and panels and tabs.Now, there may be cases where we need to traverse the tree, and trees present us with a very natural way to traverse them- recursion. To search the tree, first search the subtree. Recursion can have its own problems, but the UI tree of a native application is rarely deep enough for those problems to be an issue.Nick inherited some VB .Net code that iterates across all the controls in the screen. It does not use recursion, which isn't a problem in and of itself. Every other choice in the code is the problem.
CodeSOD: Replacing a City
Mateus inherited some code where half the variables were named things like strAux1 and strAux2. It was a data driven application, and the data had some conventions that weren't always ideal; for example, every city also had an associated abbreviation stored in its name field, e.g., "SAO PAULO (SP)" and "RIO DE JANEIRO (RJ)".The original developers wanted to be able to present the names of cities without the abbreviation, so they wrote this:
CodeSOD: Name a Valid Email
Correctly validating an email address, per the spec, is actually surprisingly hard. This is, in part, because there are a lot of features in the email address that nobody ever uses. Even so, you can easily get close enough with basic regex, and that's what most people do.Niels H's predecessor wanted to go a little farther. They wanted to ensure that the supplied domain name had a valid DNS entry. Overkill? Probably. But, fortunately for them the .NET framework supplies a handy System.Net.Dns.GetHostEntry method, which resolves a domain name. That at least makes the problem easy to solve.It makes the problem easy to solve if you use it. But why use a built in method when you can do it yourself?
CodeSOD: Pretty POed
"QPirate" was debugging an issue with purchase order version information. The format was supposed to be "Revision#.Version#", essentially "major" and "minor" versions for the various steps as the purchase order wormed its way through the company's incredibly complicated purchasing process.Unfortunately, that isn't what was happening. Many numbers behaved in unexpected ways when they were versioned too many times. QPirate dug in, and found this:
Error'd: Grasshopper
One of my multitude of peeves is the phrase "special characters." Somehow,our lexicon has been corrupted by semiliterate middle-schoolers,who have never learned that the name for ,.;: and so on ispunctuation and/or symbol. Dustin Hoffman's Raymondwas a special character. Period ain't.This week,Robert F. had the misfortunate to step into it, and observed "What boggles my mind is that someone had to activelychoose to create a validation rule specifically for this."
12345678910...