Feed the-daily-wtf The Daily WTF

Favorite IconThe Daily WTF

Link http://thedailywtf.com/
Feed http://syndication.thedailywtf.com/TheDailyWtf
Updated 2025-12-16 07:31
A Petite Change Request
Robert ran a web service used to store legal file data for a number of clients. One day, he received an email from his biggest client, Excédent, asking to meet about a new requirement."We've purchased new accounting software that requires us to track an additional piece of data," Philippe, Robert's contact from Excédent, explained over the conference call a few days later. "Each of our cases must now have a ‘cost center' associated with it. There are a lot of these cost centers, so when our employees enter case data, we'd like for them to be able to pick the one they need from a list."Robert frowned in thought. "Well, you guys already use every available field in my database. This would require me to add a new field to the database and web forms." A database change on a web service used by many clients wasn't horrible, but not exactly a prospect Robert relished either."Is that a problem?" Philippe asked. "We're getting a lot of pressure from above on this. We really need it as soon as possible."Robert couldn't refuse his largest client. Besides, it was one measly field. "No, it should be OK. I'll figure out the nitty-gritty details myself. In the meantime, can you put your cost centers in a spreadsheet and send them to me? I'll import them into the database when I'm ready.""Sure!" Philippe said.It didn't take Robert long to create the new cost center table (VARCHAR(100) seemed safe), link it to the case data tables, and update his web forms with a new dropdown field. However, the spreadsheet from Philippe took longer. Much longer.Where the heck is this thing? Robert wondered. Wasn't this supposed to be "urgent?"Over the following several weeks, Robert sent a few gentle prodding emails. Finally, Philippe responded. Sorry for the delay! I was cleaning up the data. The list is about half as long as it used to be. Thanks!Robert smiled. That was nice of him, whittling down the list to, what a couple hundred or so? Time to import them and test everything out…He opened up the spreadsheet- and froze in horror.Robert realized he'd made one of those terrible assumptions we all make from time to time: believing a client's simple request was just as simple as it sounded. There were nearly 1800 "Cost centers" in Philippe's spreadsheet, each one with 17 fields (four of which aren't visible in the screenshot).Excédent employed 3600 people. Philippe claimed to have whittled the list down by half- meaning that before he'd scrubbed the data, there'd been nearly one cost center per employee.Robert scrolled up and down the spreadsheet in mute horror for several minutes before grabbing the phone and ringing Philippe's desk. "This is kind of a lot of data to put into a dropdown," he explained, heart pounding. "Is there any way to simplify this further?""No, sorry," Philippe said. "That's the best I could do."Who's going to scroll through 1800 cost centers every time they log a case? Robert wondered. Panic transitioned to desperation. "I think we need another call."A week later, Robert met with the client to explain that the "cost center" ""field"" was simply too complex for him to accommodate. They decided not to import the list after all, and to have employees manually enter cost centers into a text field (ex. "345 Water Distribution"). Not optimal, but it worked.To Robert's complete lack of surprise, a quick browse of those values manually entered over time showed that only a tiny handful of the 1800 cost centers had ever been used.[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!
CodeSOD: Are You Down With PHP?
Who’s Down With PHP?PHP often gets a bad rap. A lot of the time, that’s because it’s used by developers that don’t know what they’re doing, just like there’s nothing inherently wrong with spandex, but there are times, places and people where it is inappropriate. And don’t get me wrong, the language has made big strides in recent years (good luck finding a web server hosting one of those versions, though). But there are just uses of PHP that reinforce that reputation. Robert Osswald provides this example from the contact-form editing code of a domain registrar database.Let’s say you have some JSON data from an AJAX request, and it looks like this:
The A(nti)-Team
In the 1980’s, there was a TV show called The A-Team. There was the scrounger, who could scam anyone out of anything. He would make promises that were sort of true to get what he wanted (sound like marketing?) There was the tough guy who could intimidate anyone into doing anything. He knew how to get things done, but underneath it all, was a nice guy. There was the leader, who could always come up with a plan to save the day. And there was the one guy who was a little crazy (the good kind of crazy), but who you could count on in a pinch. There was also the occasional outside helper who would run interference and recon. This was a group of folks who worked as a well-oiled machine to get the job done. Failure was not an option! They were a team!The A-Team never filed a project methodology document. No wonder they were wanted criminals.Alex had taken a job on a new greenfield development effort to replace an aging and unsupportable birds-nest-o-wtf™. Naturally, the position was advertised as “we intend to do things right!” The project is fully funded. We will have the proper equipment and team personnel to get this job done. We have the full support of six layers of management plus all of the users. Alex was optimistic.The first thing they did was spend several months wrapped in those numerous layers of management, end users, support folks, senior people who used to support the project (to explain the problems that plagued the old system), and the three architects of the new system. The new architecture was heavily documented, presented to and signed off on by all of the above. It was even reviewed with a critical eye by an independent third party regulatory auditing agency to ensure that the overseeing authorities were confident that the correct approach was being taken.An 8 page document detailing development coding guidelines (e.g.: code formatting settings, naming conventions, unit tests, code coverage and other such team-wide items) was created, reviewed and decreed to be followed by all who worked on the project.The project was off to a good start.Job one was to hire the development part of the team. For this, they looked (very far) offshore to find the cheapest possible talent. After all, anyone can be trained, right? A team of 11 developers who collectively had 13 years of experience, and a team leader with 5 years of experience were hired and put in place.The next major decision was which database should be used. There were three in widespread use at the company. Since all of the databases were hosted on centralized servers, one was immediately ruled out because the hardware that hosted the data servers was insufficiently powerful to handle the expected load in a reasonable time frame. Of the other two, one was widely used by everyone on the team. They knew its syntax, quirks and limits. The the third was mis-configured to have a reputation as being flaky. However, that one also was the corporate standard. In spite of the objections of the team, they used the third one.Project management decided that QA folks could be brought in later.Finally, it was time to begin doing detailed design. The offshore lead decided that a lot of time could be saved by doing design on-the-fly as required. Of course, the architects objected, but the project manager agreed to it.And so the architects started working on building the controller engine and other such mainstays of the project. The junior team, which was to query numerous remote systems for input data, merge, filter and pre-process it, decided that they knew better than what was specified in the architecture document, and started designing their own way of doing things. Without telling the architects or management.Come time for the first sprint check-in and all sorts of red flags flew up during code reviews. The junior lead decreed that the architecture document was only a suggestion that could be ignored in favor of the developers desires. Naturally, this spawned lots of are-you-f’g-kidding-me’s and emails up the chain. The project manager and above seemed disinterested, saying that the junior developers shouldn’t be doing that, but we trust them to do the right thing.This went on, with the architects pointing out implementation flaws and shortcomings that would not support the requirements. All suggestions were ignored, because the offshore lead said “Google fosters an environment of innovation and creativity; we should too!” He was reminded that Google is (in large part) a think-tank, and that this was a highly regulated project within a highly regulated industry. The architecture, which had been signed off by more than 40 managers, was not optional or a suggestion, but mandatory. This was not kindergarten, where creativity is fostered; you had to stick to the approved plan! Now, we’re not talking about how to write a subroutine, or encapsulate an object; we’re talking about using threading incorrectly and in the wrong places, doing database accesses and interprocess communication in such ways that would not be scalable, or provide enough throughput to finish daily runs by regulatory deadlines. Spawning multiple processes instead of just using threads. Using files to act as semaphores, because that’s how they did it in school. The list goes on.None of that mattered. The junior developers resented that they were not consulted on the architecture, and so were bent on ignoring it - with the blessing of their lead. The project manager continued to acknowledge the problems, but didn’t do anything about them. The problems were reported up the chain, and nothing was done. Everyone on the team should have an equal say in things.In the real world, if a student thinks the teacher is wrong, he doesn’t get to change his grade. The surgical resident cuts where the surgeon says and not the other way around. The general doesn’t discuss strategy with the privates. If you join a union, and as the new guy demand to have equal say on policy with the union bosses, you’ll be bunking with Jimmy Hoffa. Experience speaks with exclamation points. Inexperience speaks with question marks.Except on this “team”.The junior developers continued to do what they thought was best, ignoring the architects at every turn. Much of their code was written and rewritten several times over because the designs by the juniors didn’t take things into account. Things more experienced folks know to plan for. By the time 8 months had passed, so much damage had been done that some of the more complex requirements simply couldn’t be hooked in, and more than a month of back-pedaling had to be done on a greenfield development project.About this time, management acquiesced and asked some of the business users to write business-level tests (e.g.: via a spreadsheet that would be fed into JBehave to JUnit test things). The developers would provide the underlying code and some sample entries in the spreadsheets. The architects said that QA folks should be hired because business folks rarely know how to deal with edge cases, precision issues, etc. But the money was not to be spent. After six months of effort, the business users proudly decreed that all the tests for the entire application (e.g.: the entire requirements document) had been set up. A five minute glance showed that they didn’t handle edge cases, null cases, precision cases, or most of the other things that usually require tests. In fact, they had put all of the records that could possibly be processed (at least in their minds) into one giant pass-fail test. Of course, when something changed and it inevitably failed, there was no way to know what failed.Finally, it got so bad that the architects built a physical wall in the code between the setup code (written by the offshore folks) and main engine (written by the architects) sections of the application. Immediately before the main engine began to grind the data, every single variable in the system would be flushed to a state table in the database, so that when something would inevitably be challenged, they could show the inputs that were provided and send the fix-it work to the offshore team. At least this way, they could insulate the main engine from the debris.The department saved a lot of money by using cheap labor, no QA folks and the politically expedient database. Of course, all of the code of the setup portion done by the offshore team was a disaster, and for the most part, very difficult to learn, support, debug and enhance.The product hadn’t even been deployed yet, and the users were already complaining that it took too long to diagnose and fix problems (one of the main reasons the whole rewrite project was authorized), that perhaps the rewrite wasn’t satisfying the main purpose of the rewrite, and that perhaps something might be wrong…[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!
CodeSOD: Regularly Expressing Hate
Perl is jokingly referred to as a “write-only language”. This is because Perl’s primary solution to any problem is to throw a regular expression at it. Regexes are powerful, but cryptic. Imagine RJ’s joy at starting a new contract for an OCR/document-management system that makes heavy use of regexes. Even better, the system doesn’t use widely implemented “Perl-compatible regular expressions” syntax, but instead, uses its own, slightly tweaked version.So, for example, when the system needs to pick the document ID out of the scanned document, it uses this regex:
Error'd: Pretty Please?
"Hey, may I get your permission...quickly? I'm about to leave for a world tour and I have a LOT of ground to cover," writes John
The Record Setting Score
A few years ago, Joel Spolsky wrote his simple, 12-point test to measure how “good” a software team is. Stan was thinking about this test quite a bit, when he started a new job at a company which set a new record for failure.Stan’s journey started after an excited recruiter told him, “I have a great role for you, working for a cutting edge online retailer in London!” Stan became a Senior PHP Developer on a team of three others. Each day there, he asked another question from the Joel Test.Let’s review Stan’s experience against the 12 questions from the Joel Test.1. Do You Use Source Control?Stan asked about source control during the interview, and the interviewer replied, “No, we don’t have any at the moment. But we will soon!” When Stan started, he found that the only copy of the source code was the live website. Any changes meant downloading the site, altering the files, and re-uploading the changes over FTP. He very quickly got used to hearing the question, “Is anyone changing users.php?”, or “Hey, where are all my changes from yesterday?!” Having four people work on a live website using only FTP to synchronize work caused friction, like throwing sand in an engine.Joel Test Question 1: Fail2. Can You Make a Build in One Step?Building should be as easy as possible. The best solution is to have a script which can handle the entire build process from start-to-end. Check everything out from source control (if you have one!), compile binaries, and create the installation packages. Without this, building will be error prone.Without source control, and without any concept of development servers or test servers, “builds” were deployed via FTP. The team made database schema changes by uploading specific PHP scripts with the required SQL and loading them as a page while praying that nothing breaks. When things did break, it was extremely difficult to debug or rollback the changes. I’m not sure “build” or “release” are even valid terms for this company, any more than “architect” describes a kid who lobs globs of mud at a wall.Joel Test Question 2: Fail3. Do you make daily builds?Daily builds make sure your repository trunk is in good working condition. At least once a day, obvious errors like incomplete check-ins or missing dependencies are easily discovered, and discovered early, before any software enters production use. The term “daily build” implies some sort of integration and testing environment, not ad-hoc FTP uploads to a live site.Joel Test Question 3: Fail4. Do you have a bug database?You need a good way to track defects. What’s the error? Who reported it? How can it be reproduced? What’s the priority? When was it fixed? Of course, tracking bugs is meaningless when one developer’s FTP upload can overwrite another developer’s previous efforts, causing the bug fix to be lost for all eternity.Joel Test Question 4: Fail5. Do you fix bugs before writing new code?Stan’s company fixed bugs all of the time, as any software firm must. However, those bugs regressed all the time too, since one developer’s fix could easily be rolled back when another developer uploads their version of the PHP file a few hours later. This methodology ends up like this.Joel Test Question 5: Fail6. Do you have an up-to-date schedule?Having a schedule would mean having a list of features, a timeline by which they need to be finished, and priorities to help determine what gets in and what doesn’t if the timeline slips. Instead, Stan had a constant stream of emails, memos, and Post-It Notes handed down from management.Stan might be half-finished with a “top priority” feature when a different director would storm into his cube. “Did you fix my issue yet? Get on it! Now! NOW! It’s an EMERGENCY!”Joel Test Question 6: Fail7. Do you have a spec?Good software has some kind of list of requirements, or at least a description of what the software should do. For Stan, his “spec” was determined by which director was currently in his cube, screaming about their personal fire that needed to be extinguished. It’s only by the grace of good fortune that his cube was too small for two directors to be badgering him at once- that situation might have come to blows.Joel Test Question 7: Fail8. Do programmers have quiet working conditions?“Are you aware of the exciting new opportunities available to you, with our products?”One of the many “top priorities” for their company was marketing, so they hired a stable of telemarketers. Short on office space, they stuffed them in the only place that was free: next to the development team. Within a few days, the developers wanted to chop off their own ears, just to quit hearing the marketing script on endless repeat.“Are you aware of the exciting new opportunities available to you, with our products?”Some offices invest in cheap white-noise generators to cut down on that sort of cross-talk. Stan’s wasn’t one of those.“Are you aware of the exciting new opportunities available to you, with our products?”In fact, the office had other infrastructure problems. When winter arrived, the building’s heater broke down. Working from home was out of the question- how could directors storm into your cube to “clarify” priorities? Instead, everyone was forced to work in the sub-zero office.“Are you aware of the exciting new opportunities available to you, with our products?”Developers huddled in their cubicles, wearing coats, hats and gloves. Imagine the quality software written by a team-“Are you aware of the exciting new opportunities available to you, with our products?”-wearing gloves, in the freezing cold, while listening to the steady mumble of marketing copy.Joel Test Question 8: Fail9. Do you use the best tools money can buy?Developers need to have powerful PCs. If you give your development team a stack of Pentium M laptops with single-core CPUs and 512MB of RAM in 2015, they’ll spend 90% of their time standing on their rolly office chairs and fencing with makeshift swords, or just watching Chrome cry while rendering web pages.When Stan first started, he was assigned a nice, shiny MacBookPro, stuffed to the gills with RAM and an SSD. Shortly after he got it set up for development use, the sysadmin informed him that this was a requisition mistake. “This machine was actually for one of the new graphic designers. You get this one.”The replacement was a 5 year old machine that was suitable for email, Solitaire, and virtually nothing else.Joel Test Question 9: Fail10. Do you have testers?Stan’s company almost wins this one on a technicality. While they didn’t employ any testers, they had customers. They were abused as testers, since they would naturally call in and complain when ~a software release~ big ball of mud was FTP’d to the live server.A generous grader might be tempted to give partial credit for this, since they at least recognize that testing needs to happen. But let’s repeat this: their customers were their dedicated testers on a production website.Joel Test Question 10: Double Fail11. Do new candidates write code during their interview?During Stan’s interview, he was not asked to write any code. In fact, his interviewer didn’t speak English terribly well, so the interview was mostly the two of them smiling and nodding at each other. It probably didn’t matter, since most of Stan’s day wasn’t spent writing code- it was spent rewriting the code that got deleted after the last FTP-based screw-up.Joel Test Question 11: Double Fail12. Do you do hallway usability testing?A good way to test is to grab a random person as they walk through the hallway, and force them to use the software you just wrote. They don’t work on your team, and may not be familiar with the project or its requirements. Can they use it? Is it intuitive? Does the user interface make sense? This is a great way to discover usability issues that developers easily overlook.In Stan’s company, they sort of did the opposite. Random directors would storm into Stan’s cube, not to try the software, but to dictate a new mandate without any thought to whether or not it made sense.Joel Test Question 12: Reverse FailTotal Score: –2.0000000000000000001420001, thanks to two double fails, and the floating point rounding error is caused by the Reverse Fail.As the new Senior PHP Developer, Stan fought to clean things up somewhat. He got a Subversion server set up on a spare box, and managed to get a development server with a clone of the live system. In a few months, they started working almost like a “real” software team. Productivity went up, bugs got patched before users saw them, and FTP-induced rework was almost entirely killed.Sadly, after all these changes, management called in the team and complained that they were all overpaid, lazy, and a drag on the company. Stan quit on the spot, and over the next few days, the rest of his developers followed him. Weeks later, he heard through the grapevine that they’d brought on a new team, and were undoing Stan’s “wasteful” changes.Apparently, the highest priority directive was to ensure their record-setting score on the Joel Test.[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!
Announcements: The Daily WTF: LIVE!
You’ve read the posts. You’ve submitted your own WTFs. Now it’s time to take it to the next level: The Daily WTF: Live is coming to Pittsburgh, PA.In the style of The Moth or Risk! podcasts, we’re getting our fellow IT drones up on stage, to share their tales of their worst WTFs, their successes, and true tales of life in the IT trenches.The live show is April 10th, 8–10PM at the Maker Theater in Pittsburgh. Tickets are available now.Don’t worry if you can’t make it to Pittsburgh. We’ll be recording the show, and sharing the best stories here on the site from time to time, in addition to our normal stream of WTFs.If you’re in around around Pittsburgh, and think you’ve got a killer story and want to get in front of those lights, we still have open slots for storytellers. Send a brief (1–2 paragraph) pitch for your story to storytelling@jetpackshark.com, and Remy will be in touch to discuss. (Your story doesn’t have to be a pure WTF) We'll work with you to build up a great 8-10 minute piece you can perform.This event is brought to you by our awesome and proud sponsor, Puppet Labs*. As we mentioned in their sponsorship announcement article, thanks to their support, we’ll be able to create some exciting new content, do more meet-ups, and have a lot more fun all-around. This is an example of that and we are still very excited to be working with them! Check out their intro video, it gives a pretty good overview of how they help their customers get things done.We’d also like to thank Code & Supply for helping us network with the Pittsburgh IT community. Code & Supply is the largest IT community group in Pittsburgh, with frequent meetups and a variety of activities. They’ve helped connect us with performers and are helping promote the show with their community. They even let this guy give a talk on using storytelling to communicate technical details.[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
CodeSOD: A Deeply Nested Mystery
As any competent developer knows, not all Web browsers were created equal. In a stew of standards, drafts, vendor extensions, and JavaScript engine quirks, each of them can behave a little differently under various circumstances. Many people tried to resolve this situation, but "creative" coders are always one step ahead, finding new and amusing ways to mandate the dreaded "runs only under Internet Explorer 6" popup on their webpages.This time, our submitter found out that his bus timetable was working just fine on Safari:Under Firefox, however, it was curiously missing one of the schedules:Is it a JS compatibility hack gone wrong? he wondered. Maybe a badly-placed -webkit- prefix? Curious, he checked the source.It was neither. Instead, the author of the code just really, really, really wanted the link to be blue:
Dynamic Tables
We've all learned to write programs a bit more generically than the immediate problem requires. We use interfaces in our code and include concrete implementation classes via some language-appropriate mechanism. We use factories to produce the object we want, rather than hard code them. We use code generators to spew forth mountains of code from configurable templates. Sometimes, we even generate SQL on-the-fly. It provides more flexibility that way; instead of having to write a separate query for every permutation of question, we can write something that can dynamically create the query, execute it and return the results.At Initech, Ian was assigned an interesting JIRA ticket: Investigate errors regarding column length. Since that was all the information written in the ticket, Ian hunted down the author of the ticket to pry out a tad more information. Apparently, the part of Initech's intranet website that was used by the sales agents was suddenly throwing errors about some kind of maximum-size error, and he needed to find out what it was, why it was happening and how to fix it.Sounds routine enough. Someone probably overflowed some buffer somewhere, or had too much data to fit in some column in the database.The website in question was nothing out of the ordinary. It was written in PHP using the Zend framework connecting via PDO to a MySQL database. It had been mostly written by several programmers who had left the company a few months prior, and was of a quality that was not unusual for a corporate PHP website. There were functions with reasonably sensible names. The MVC pattern was applied in a rational way. It was possible to follow the code structure without retching or having seizures.Of course, since this was a fairly decent sized company, there were also the requisite SQL injection vulnerabilities on every single input field. No input was ever sanitized; not even manually. There was no error checking on query result sets. Countless uninitialized variables littered the landscape, scattered amongst informative debug statements like: echo("whyyyyyyyy?");The page producing the error was written by Gary. It was a multi-tabbed form with only some minor WTFs. One drop-down box had a completely different look&feel than all the others on the page, and any kind of error more complicated than a validation error produced the error message "1".Sales agents were supposed to use it while talking to customers to enter information about the person they were calling. The error they were getting was a MySQL error regarding maximum row sizes, but it wasn't because of too much data in an input field. After a double-take and a quick Googling, Ian found that yes, MySQL -does- have a maximum size on the length of a row, namely 64KB. But this was just an Insert statement, right? What would maximum row length have to do with an existing table schema?After several spelunking sessions down through the fetid bowels of the system, Ian found the fecal mass of detritus that was causing the problem.It turns out that Gary was being micro-managed by the VP of Operations. This led to an endless series of requests to add a new field to the form. Gary got tired of doing the same work over and over, and took it upon himself to automate the problem. To this end, any time a new field was added to the form (usually by someone SSH'ing onto the remote server and just editing the necessary PHP files directly in production), the page would later on detect that the database did not have a matching column for it, and would create an alter table statement to add the new column to the database. Automatically. On the fly. With no human knowledge of, or intervention thereof. Live. In Production.The fact that it had lasted several months without causing some kind of outage was impressive.The name of the new column was the ID of the field on the form. But what would the data type be? The answer Gary settled upon was... varchar(255). Fast-forward a few months; all those varchar(255) columns started to add up, as management decreed more and more and more fields for more and more and more customer data to be recorded. While having a database table with 200+ Stringly-Typed columns is a WTF in and of itself, the fact that they were automatically added and with a substantial size only made the problem worse, particularly as 255 characters was far more than necessary for most fields. Two-letter state abbreviations, 5-digit Postal codes, 4-digit Zip+4 postal codes, 8-digit customer IDs, apartment numbers, phone numbers, and many others were all blanketed under the varchar(255) datatype.While Ian wanted to tear out this monstrosity and banish it to the recesses of the Git commit log, he was informed by his boss that, since the Intranet website was going to be taken down in a few months, it would be more prudent to simply resize some of the columns to buy them enough time to take the whole site down. And so, choosing some of the more egregious offenders, Ian altered ten columns or so to reduce them to a sane size (or, better yet, to turn columns holding integer values into actual Integers).[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!
Announcements: Free (New) TDWTF Mug Day - Time's Running Out
There's only so much time left to get your free TDWTF mug, with the new logo and everything. Be the first kid on your block to have one.Last year around this time, we did a Free T-Shirt Day. You all gave some great feedback, so I thought we'd try it again with a Free Mug Day!My company, Inedo, will be once again sponsoring this round of The Daily WTF mugs. Although we haven't yet released our v5 of BuildMaster yet, we've made a lot of big improvements since last year, and thought this would be a good opportunity to show them off. The mugs will be the same, serious grade as always -- but this time, they'll feature the brand-new logo (unlike the one below).
CodeSOD: Negative Creativity
Pop quiz: how do you ensure that a number is negative? You could do something like:
Error'd: Merry Christmss
"I'm not sure what happened...maybe they ran out of vowels?" Mitch wrote.
The Awesome Optimization
Dave liked to think that he was a responsible, thorough application developer. He always tried to understand a problem before tackling it, to think through all ways a change could affect things, and to gather information before making decisions. So when he received complaints about the speed of the custom web application used by his work’s health department, he decided to do a little research to gather all the facts before reporting the issue to his boss.And sure enough, all it took was a little research: the logs were full of database query timeouts and memory limit terminations. After a small amount of performance analysis on the test database server, it was very clear that the database was by far the main cause of the slow speeds. As the number of entries in the database naturally increased, many of the queries became exponentially slower.Satisfied he had actionable information, Dave went to his boss to get approval to make fixes.“Thank you, Dave! But the database isn’t your job - you’re an application developer. Anything related to the database is the DBA’s job. I’ll get ‘Awesome’ on this right away.”‘Awesome’, the affectionately-nicknamed-by-the-boss local Database Administrator (DBA), had no experience programming, but was considered “master of all things even tangentially database-related”. Dave tried to make his boss aware of an important caveat: “But the data access code is in the application. How can the DBA optimize it there?”His boss was resolute: “That. Is. Not. Your. Job. Don’t even worry about it. I’m sure Awesome knows how to do it.”And so instead of optimizing queries, Dave begrudgingly set up another testing instance of the application for Awesome to work with and handed over the details. Three days later, Awesome showed up at his door with bad news: “The application is completely broken.”Incredulous, Dave logged in to debug a little and quickly discovered that the “web.config” file had been modified and was pointing to an incorrect server. “Awesome, please do not modify any code or application settings without letting me know. Modifying the web.config file can be dangerous if you don’t know what you’re doing. Just optimize by profiling the database on the testing database server - you don’t need to dig through the code.” With a glare, Awesome left, never to be heard from again.Until 5 days later, when he showed up at Dave’s door with amazing news: “It’s done.” Again incredulous, Dave logged into the test instance… and was shocked by how fast it was. Every page loaded nearly instantly. Even complex records searches displayed results immediately. Not a single perceptible delay remained.“How did you do it?”, Dave asked.Awesome was recalcitrant: “You don’t need to know. It’s not your job. All you need to know is that it’s a lot faster, and I did my job.”Dave pressed him further. Had he modified any code? Had he added any indexes? What changes had he made?
CodeSOD: Waiting for File IO…
Trisha had the misfortune to inherit some old Cold Fusion code. One particular block needed to see if a file existed before it continued, and apparently the original developer really wanted to be patient and make sure the file was there, so they wrote this:
The Lockdown
2014 was waning, and Stacy’s team was struggling to deliver all the projects the director wanted before year-end. Insuracorp was a small, and that meant IT had a minuscule head-count. This meant they needed to bring on a Highly Paid Consultant for the last project, Codename: Lockport.A manager had read a dire article about hackers dropping thumb drives in a parking lot, which their victims then picked up and plugged into their computers. This meant that it was now absolutely vital for the organization to ban all unapproved USB devices from being connected to the company systems. George, the HPC, was a hardware expert, so he’d been running the show on Lockport while Stacy and her teammates cranked through the rest of the project list: upgrade mailservers here, replace a macro-laden Excel sheet with actual software there, discover that an Access database was suddenly “critical to business operations”, and the business wanted it ported to SharePoint. It had been a busy year, and Stacy was ignorant of George’s progress until her boss, Jeff, appeared in her cube one day.“Morning, Stace! Great work on that Exchange migration. I need a favor: George really could use a hand with Lockport. I’m not sure what the issue is, but he’s not making quite as much progress as we’d like, and year-end is closing in on us. If you could give him a hand, that’d be great.”Stacy obliged, and took the elevator down to the basement room where George waited. His shiny bald spot was the only thing visible above the piles of USB devices teetering on every surface of his makeshift office.“George?” Stacy was inclined to whisper, fearing the slightest reverberation would bury her co-worker alive.“Can’t figure out…” George said, trailing off into mumbled profanity. Stacy approached carefully, finding the round, red-faced man hunched over his laptop, popping the USB cable of a mouse into and out of each port in turn, as though performing a Zen ritual.“George? It’s Stacy, from upstairs. Jeff asked me to come down and see if you needed a hand?”“Not unless you can find a way to keep a USB device on the whitelist when its hardware ID changes every time!”That took Stacy aback. USB hardware IDs were burned into the device by the manufacturer, and she wasn’t aware of any circumstances under which they could change. Then again, George was the “expert”. Maybe he was doing something unusual.“I didn’t think that was possible. Can you show me?”Stacy peered over a stack of removable hard drives, careful not to send the pile tumbling to the floor. George was using an app called DevViewer to see the hardware IDs of the devices he was testing. The window showed a simple tree-view that organized all connected devices by category. He pointed to the mouse, named VID_081&PIT_1001, under the Human Interface Devices category, and told Stacy to watch closely. He unplugged the mouse; its entry vanished from the list. After a five-count, he plugged it into a different port. He immediately selected the last device in the HID category, outlining its ID in a damning blue highlight: VID_0A81&PID_3016.“SEE?!” George said. “It’s that… that dam PID! How am I supposed to whitelist all of these in the Endpoint Protector whet the Port ID changes every time I plug them into a different port?”Stacy blinked rapidly, wondering if the dusty atmosphere of the basement had messed with her vision: she was quite sure there had been three devices in the HID section, and now there were only two.“Is the…” Before Stacy could finish her thought, George yanked the mouse out of the second port and jammed it into a third.“And this time it’s the same! It’s maddening!”Before George could pull the plug once more, Stacy reached over and clicked on the disclosure button for the “Other Devices” tree. There, plain as day, was VID_0A81&PID_1001. “Now, just give it a second,” Stacy said. Sure enough, the mouse’s ID vanished from “Other Devices” moments later, only to reappear under HID.“When you first plug it in,” Stacy said, “it takes a few seconds to load the device drivers. Until it does, the device just registers as ‘Other’, and that’s why it looks like the IDs are changing. They’re just moving between the two lists.”George sat back, eying the devices heaped around him. He looked everywhere but towards Stacy. She’d just shown, with a simple observation, that the past few weeks of struggle against capricious device IDs had been pointless.Stacy tried to fill the silence. “I guess that’s why a second pair of eyes is always useful, huh?” A twitch in his left eyebrow was George’s only response.Though he never spoke to Stacy directly, George managed to communicate through Jeff that her input was no longer required. She figured he hadn’t liked being shown up, and was more than happy not to visit the basement again. Stacy returned to her project list and forgot about Codename: Lockport.The year wound down, and on New Year’s Even, Insuracorp’s virtual server environment ground to a complete and total halt. Access Denied and Unexpected Error dialogs graced the screens of every workstation, and Jeff scrambled the IT squad to investigate.“Stacy, look at this,” Steve said, pointing to the dashboard of the database server he administered. “The system disk is here, but it says all the other drives, including the data drives, are unmounted! Could this have to do with Codename: Hot Potato?”Stacy scanned the list of red-lit, unmounted drives, her teeth clenched. Hot Potato was a virtualization project she and a few virtualization specialists had wrapped up. Its purpose was to reconfigure several dozen VMs so they could hot-add CPU and RAM. That mode was all-or-nothing: the VM disks became hot-addable as well, causing them to be treated as removable storage.“Removable storage,” Stacy muttered to herself.“Huh?” Steve said.“… like they were USB drives. Jeff!” Stacy yelled across the cube farm, prompting her boss to jog over.“What’s up? Figured it out?”“That depends. What’s the latest status on Codename: Lockport?”“Hmm…” Jeff consulted a spreadsheet, awkwardly loaded and displayed on his omnipresent BlackBerry. “Right. Since the Endpoint Protection config never panned out, George decided to block all USB drives via group policy. Looked good on his test machines, so he rolled it into Production…” Jeff looked up, chewing his lip, “this morning.”Stacy made an unhappy sound that rhymed with “duck”. Steve looked between the two, knowing only that whatever was going on wasn’t good. As a junior database admin, he hadn’t been privy to either Hot Potato or Lockport. “Guys?” He asked, “What are we going to do?”“We’re going to revoke that group policy,” Stacy said. “Then the VMs won’t be banned from accessing their own storage, and then we can have George give Endpoint Protection another go.”“Forget it,” Jeff said. “It’s a new year, and I think it’s time for a new hardware ‘expert’.”[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
Coded Smorgasbord: Dating Woes
As we all know- especially those of us who just "sprung ahead" this weekend with Daylight Saving Time- dates, times, and time zones are complicated beasts. Handling them programmatically is even harder. Computerphile put together a great video on this topic, which is worth watching to understand why we receive so many Error’d submissions regarding downloads that claim they won’t finish until after the heat death of the universe.Here are some examples of mind-bending code attempting to wrangle with an already mind-bending topic...First up, Tom discovered this date formatting gem in an inherited application, in the Page_Load of several pages:
Error'd: Spoiler Alert
"The following image contains spoiler information. Due to the fact the material in this image will spoil upcoming errors, we have removed the excerpt so you must click the image to view the image contents," writes Jay M.
Spared No Expense
Renee’s company was a Silicon Valley managed services company. They needed the best data-center they could find to house their infrastructure, and cost was not an object. They loaded up a dump truck full of money and went shopping for the most expensive hosting they could find.For Renee, this meant lots of data-center tours. She played the tame geek for her management, ostensibly there to inspect the IT services. Her bosses were just there to see how much their prospective vendors would butter them up to close the deal.The front-runner was a company called “Isla Nublar”. Their first experience on the tour was a massive security gate, guarded by two armed men and a dog. They gave the entire car a quick search, including using mirrors to inspect the undercarriage. After being sniffed over by the dog and having their ID checked and re-checked, Renee and her bosses were allowed through.The building itself came from the “an alien spaceship has landed” school of architecture. It was steel, glass, organic curves and confusing arcs. A security guard and a sales engineer named John greeted them at the door. “We’re so excited to have you here,” John said. “As you’ll see, we’ve spared no expense.”He showed them into a glass-walled atrium, full of natural light, tropical plants, and a catered spread laid out on a table, complete with coffee, macarons, and a sushi chef making rolls to order. “Can I interest you in any refreshments? The coffee is Kona- we’ve spared no expense.”John showed them down the hall to the NOC. Behind the glass wall, staff bustled about the room, mostly ignoring the Mission Control-style wall display, and focusing instead on their own screens. Everyone looked busy, but didn’t actually seem to be doing anything. It reminded Renee of animatronic figures in Disneyland’s old “Mission to Mars” ride, and they seemed about as useful.“As you can see, we’ve spared no expense. Now, let me get you ready to see the data-center floor.”“Getting ready” meant filling out piles of paperwork and NDAs, collecting everyone’s fingerprints, mugshots, and patting down everyone to ensure they weren’t smuggling a cellphone camera into the data-center.The entry to the data-center floor was through a man-trap, the security version of an air-lock. One at a time, they passed through the outer door, and an armed security guard waited for it to seal before pushing the button that released the inner door. After everyone cycled through, John reminded them, “We’ve spared no expense.”Over the noise from the racks, John shouted out the key features. The floor was raised, and each tile had a dedicated sensor to detect if it were moved. There were motion sensors, water sensors, and a few times, John mentioned “laser beams”. Every millimeter of the space was watched by cameras, and the room itself was a Faraday cage. The supports were earthquake proof and the walls were lined with Kevlar. They had triply redundant backup generators, and each rack had dual, independent power legs, in case anything went wrong with one of them. Each rack was secured with a grille that could only be opened with an admin’s ID badge.“As you can see,” John began.“You’ve spared no expense,” Renee finished. “I get it.”Duly impressed, management signed the contracts the next day. That weekend, Renee and her team had to move their hardware in through the “secure loading dock”, which was just a regular loading dock with a sign that said, “Secure Area.” None of the extremely paranoid security they had seen coming in the front way was in sight here. No one complained, because it certainly made moving in easier.By Saturday night, everything was up and running. The switchover went without a hitch, and the customers hadn’t noticed a thing.By Sunday morning, disaster happened. Machines were down, network was down, and the customers were enraged. Renee was on the phone with the data-center support in an instant, and before five minutes had passed, John joined the call, trying to smooth things over. “I just want you to know, we’ve got no other outages. We’ve got the best electricians in the business looking at what appears to be a power outage in one of your racks. We’ve spared no expense.”The first challenge for the electricians was simply getting permission to lift floor tiles without setting off every alarm in the building. They traced the power lines, but found no fault between the mains and the rack, which meant the problem must be in the rack itself.“They’re trying to trace the fault in the rack, but they can’t access the power cabling,” John explained.“What?”“Well, we spared no expense. Our racks are custom built. The power lines run inside the frame of the cabinet. I’m getting Ray, one of the admins to join the call from the floor.”“This is tricky stuff,” Ray said, “and I don’t know how quickly we can fix this.”“We need our servers up now,” Renee said.“Right, so here’s what I can do- I can move your servers to one of our empty cabinets. Sound good?”“Whatever it takes.”“We have spare cabinets,” John said, “because we spared-”“Just get our servers back up.”Ray stayed on the line while he worked. Renee heard him slide a server out of the cabinet and then say, “Hunh, that’s interesting.”“That’s not something I want to hear when you’re moving my servers.”“There’s a strange black switch down here. I’ve not seen a black switch in any of the other cabinets.”Ray checked one of the other cabinets, and sure enough, it had a bright glowing red switch. “Hold onto your butts…” Ray said. He flicked the black switch in Renee’s failing cabinet. The light turned red, and the servers spun right back up.The switch was inconveniently placed, near the floor, where someone passing by the cabinet could accidentally jostle it, which is likely what happened. Unfortunately, moving the switch wasn’t possible. With their bizarre internal power cabling, and the way the switch was soldered to the internal power strip, it would require cutting, drilling, and probably a bit of welding to move it.The only practical fix was to use tape to secure the switch in the “on” position. “We’ll use the best tape money can buy,” John said, “and it won’t come off. We’ll spare no expense!”[Advertisement] Release!is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!
CodeSOD: SearchGuard
In a professional situation, an incorrectly selected record can result in a mortifying loss of data. Therefore, it behooves one to select the proper row carefully in one's stored procedure. That's why Charles's development team uses SearchGuard, the premier design pattern for selecting just the right row:
Codename: Cloudy Viper
In the interview, Initech seemed nice enough. The managers seemed like nice, normal people, and the company’s vibe seemed quite good. When Terrence was extended an offer, he accepted and joined.
CodeSOD: Polish Elections
Far away across the Atlantic, in the mythical land of Eastern Europe, where the sun don't shine and wild beasts roam the roads, lies a little country called Poland. Known in the world for its cheap manual labor and fondness for strong alcohol, it has for years been the butt of every national joke in almost all parts of the globe. But people here (or at least those who haven't run away yet) have been working hard to combat those pesky Eastern Bloc stereotypes, and as such, the country has in recent years seen a lot of social and technological progress. That last one, of course, comes with one notable exception: the government sector.Obviously, most countries' governments have a love-hate relationship with technology- but the Polish government invariably tends to be special. Between national-level exams being leaked by putting them in an unprotected folder with directory listing turned on, and the Social Insurance department buying 130,000 floppy disks in the year 2008, our government's technological proficiency has us ranking slightly below Elbonia. And so, when it was announced that the next local elections would be far more computerized than any of the previous ones, everyone trembled in fear.The election day came and passed. At that point, everything was still done using pen and paper, so nothing had a chance to break. But soon after, the Polish Electoral Commission announced that the election results might be "slightly delayed". At the same time, someone in one of the local commissions with access to the software used in vote processing noticed an odd .pdb file with debugger symbols in the program folder. Being a good citizen, they immediately took a decompiler, restored the source code in full, and put it on GitHub for everyone to see.Now, the following part might not be for the faint of heart. Here's one of the most notable source files from that GitHub repository.This particular piece of code had one simple task: taking XML files with election results and generating an HTML file with an official election protocol. There are many ways to approach that task. The more clever people would probably go for an XSL transformation. The slightly less clever ones would use an HTML template and fill it with data. This code, however, does not try to be clever. It aims to keep things simple, using an old and trusted way to achieve its goal:
Error'd: An Odd Form Factor
"I was searching on Texas Instruments' web site when I found a block diagram for an oddly-shaped tablet," writes Renan B., "I mean, Gigabit Ethernet? PCI Express? I had no idea that they could squeeze in all these features!"
Consultant Designed Success
Circa 2005, using XML and XSLT to generate HTML was all the rage. It was cool. It was the future. Anyone who was anyone was using it to accomplish all-things-web. If you were using it, you were among the elite. You were automatically worth hiring for any programming-related task.Back then, Richard was working at a small web development company. In this case, "small" means the boss, whoe was a bright guy, but who had absolutely no knowledge of anything -web, -computer or -technology related would make all decisions relating to hiring, purchasing technology and creating technology procedures.Although Richard was trained as a developer, he had been doing some integration work on small client web sites while the company pursued bigger goals of developing a web portal framework that would allow them to pump out dozens of web portals. To help with the overall architecture, the boss hired an Architect who specialized in intelligent transactional agents. One of his claims to fame was a system he had previously built to map data to presentation HTML via XML and XSLT. The boss was impressed by his understanding and use of these technologies, and based almost entirely on just that, hired him.The architect spent several months analyzing the underlying data and all the state transitions that would be required, as well as the target HTML into which it had to be morphed. Then he spent several more months coding up the framework. One of the key pillars on which this framework was built was the extensive use of XML and XSLT to convert all the data into something a browser could interpret to render.When the consultant began to integrate his work with the rest of the infrastructure, lots of little problems started to pop up. For example, source control was really just copying the source tree to a dedicated directory on one developer's laptop. When the consultant had to deploy his latest jar, he would copy it to a network share, from which the developers would copy it locally to use it. However, at some point, the moving of the jar file became significantly less important than the using of the contents of the jar file, and the bug reports began to pile up.This particular application was basically a corporate directory categorized by region, commerce-type and category/sub-category/actual-category. There were 13 regions with about 4000 businesses, 4 commerce-types and about 300 categories. Any experienced developer would expect that searching for a specific business in region A, type B and category C would be quite fast. It would be reasonable to expect the query to complete in far less than one second. In practice, when all criteria were used, the web server timed out most search queries at 30 seconds.Apparently, the consultant decided that every little thing should be its own class. No matter how small. A data object containing a Date was insufficient. No, there were separate objects to hold day, month and year, all of which were wrapped in a MyDate object. Ditto for time. Ditto for day of week. Ditto for everything else you could imagine. Then, to really test the capabilities of the IO subsystem, network and silicon, he would query every record in the entire database, construct objects for every component, sub-component, sub-sub-component, and so forth via Hibernate, and scan the list using the slowest possible mechanism in the Java language: instanceof, to see if an object was of a particular type before attempting to use it for purposes of comparison. To make matters worse, it repeated this entire process three times for each query; once to check if each business was of the proper instance for the region, once for the commerce-type and once more for the category.Richard replaced the whole thing with a simple stored procedure that ran in less than 100ms.Having dealt with that, Richard and peers told their boss what they went through and asked him to fire the consultant. He agreed, but only after the consultant would modify his framework to support multiple portals on the same system.After two weeks, the consultant proudly proclaimed that the system now supported as many portals as they wanted. The procedure to enable this capability was to copy the entire project and rename it for each additional web portal.Having ripped out all of that framework, they never even got to try out the part of the framework that morphed data into XML to be XSLT'd into HTML.In the end, everything that the consultant did was trashed and rewritten by Richard and his peers in about a month.Upon reflection, Richard learned that just because you have knowledge of how to use one tool doesn't mean that you are an expert in everything. He also learned that an otherwise intelligent boss can make really stupid decisions if he doesn't have the requisite experience in the relevant field.[Advertisement] Use NuGet or npm? Check out ProGet, the easy-to-use package repository that lets you host and manage your own personal or enterprise-wide NuGet feeds and npm repositories. It's got an impressively-featured free edition, too!
CodeSOD: The Address Shuffle
The best thing about being a consultant, in Ashleigh's opinion, was that you got to leave at the end of a job- meaning you never had to live with the mistakes your pointy-haired supervisor forced on you.This client, an online retailer, just needed an update to their Web.release.config file to resolve their session-management issue. Ashleigh had been hired for a two-week contract, and on Wednesday of week two, the fix went live. Of course, she wouldn't get paid if she didn't manage to look busy, so Thursday morning, she was scrambling for a quick fix to add to the pile.That's when Betsy, the manager, popped by the temp cube. "Hey, I just got some new code from the offshore team. Mind taking a look at it?"Normally, Ashleigh would decline such a dubious honor; today, however, it seemed easier than digging at the growing pile of minor defects, so she agreed. The method in question was meant to eliminate blank lines in the middle of the address on an invoice, because it "looked weird" to the accounting department.Sure, whatever, Ashleigh thought. Dubious cost-savings were hardly unusual in a company that offshored their main development team and paid Ashleigh's exorbitant fees to clean up after them.
Announcements: Free (New) TDWTF Mug Day!
Last year around this time, we did a Free T-Shirt Day. You all gave some great feedback, so I thought we'd try it again with a Free Mug Day!My company, Inedo, will be once again sponsoring this round of The Daily WTF mugs. Although we haven't yet released our v5 of BuildMaster yet, we've made a lot of big improvements since last year, and thought this would be a good opportunity to show them off. The mugs will be the same, serious grade as always -- but this time, they'll feature the brand-new logo (unlike the one below).
Tales from the Interview: Limit as Sense Approaches Zeno
It’s an uncomfortable truth in our enlightened, 21st-century utopia, but we often don’t know how to deal with people that deviate slightly from the norm. Jim knows a thing or two (or three) about this, because he has a Bachelors of Science with three majors: Computer Science, English, and Mathematics. Let’s not dwell on how such a thing could be possible; consider instead the strangest reaction Jim ever encountered to his unusual credentials.The developer position at Competitive Telecom Systems seemed straightforward, and a good fit for Jim’s skills and experience. When Jim’s interview time had arrived, a man found him in the reception area and shook his hand.“You must be Jim. I’m Ted. We’re very excited to have you here today!”Ted led Jim through a maze of beige corridors to a nondescript conference room and took a seat across from one of his associates.“This is Fred,” Ted said, indicating the man across from him. He then nodded towards the third man, sitting between the two at the end of the table directly across from Jim. “And this is Crispin. We asked him to join us especially to meet you.”“That’s right,” Fred said, “he came as a favour.”Jim greeted Crispin, who said nothing, never raising his eyes from the document he was reading.Ted began the interview with a simple programming question that Jim correctly identified as a string-reversal variant before describing an effective solution. Ted nodded, but paused for a moment before asking,“So, what, did you take a few CS and English electives as part of your Math degree?”“Well, no,” Jim said. “My school offered a triple-major track, and I took it. I’ve fulfilled the requirements for all three of my majors.”“Of course, of course,” Fred said, taking the reigns from his colleague, “we just want to get an idea of where your focus lies. Would you say you consider yourself more of an Arts major that dabbles on the Science side of things, or the other way around?”“I suppose if I had to choose, I am applying for a developer role. So I see myself as a Computer Scientist first and foremost,” Jim furrowed his brow, trying to determine what his interlocutors wanted to hear. Were they afraid he didn’t have what it took to be a developer? That the variety of subjects he’d studied meant he couldn’t commit to a given task? The conversation went back to typical questions, Ted alternating with Fred, each of them unable to resist circling back to Jim’s unusual degree. All the while, Crispin remained absorbed in the document. He turned it over and over, as though trying to memorize the words on each side of the single sheet that Jim eventually recognized as his résumé. When Fred and Ted had run out of steam, and Crispin still seemed unaware that a candidate sat across the table from him, Jim leaned forward and asked if they had any other questions for him.Ted and Fred turned to their grim colleague, the one whose presence in Jim’s interview had been specially requested. Crispin let Jim’s résumé flutter to the desk, raised his head, narrowed his cold, grey eyes.“I have a question, Jim. A Math major would know about integration and differentiation, right?”“Of course,” Jim nodded. “Basic calculus…”“Yes. And a Computer Science major would have encountered the concepts of black-box and white-box testing?”“Yes, black-box is where you test the external interfaces of a given module without assuming knowledge of its internals, while white-box—”“Good. And, as an English major, you must have spent a lot of time drawing comparisons between works?”“I did, yes…” Jim leaned forward, peering at Crispin, unsure what these questions were building to.“Okay Jim,” Fred said, “Now, listen closely.”“This is why Crispin came today,” Ted added.Crispin cleared his throat and glared at his lackeys. “Here’s what I need you to do, Jim,” he said. "I want you to compare the concepts of integration and differentiation with those of white- and black-box testing.“In your own words, of course.”Jim gaped. Ted and Fred sat back, arms crossed, expressions indicating their satisfaction.“Crispin spent two days with your résumé, just to come up with that question,” Ted said.“That’s right; no one comes up with questions as challenging as Crispin’s,” Fred said. “When we saw your education history, we knew we had to call him in.”“Yes, yes,” Crispin waved them aside, “that’s fine. Well, Jim? What do you and your three majors have to say for yourselves?”Jim racked his brain, trying to conjure anything that could relate seemingly arbitrary concepts from different disciplines to one another. He was on the brink of muttering… inverse something, when reason asserted itself. He politely explained that he saw no way to compare those particular concepts. Glowering, the triad informed him that they had no further questions, and they would let him know their decision. The attentive reader of this publication will not be surprised to learn that Jim failed to get the job, and, though his career has since taken him elsewhere, he is still considering a new course of study to determine, with academic rigour, what an acceptable answer to Crispin’s masterstroke might have been.[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
CodeSOD: A Small Closing
Dario got a call that simply said, “Things are broken.” When he tried to get more details, it was difficult for the users to pin it down more clearly. Things would work, then they wouldn’t. The application would run, then it would hang, then it would suddenly start working again.He knew that his co-worker, Bob, had been doing some performance tuning, so that was probably the right place to look. “Bob, have you made any changes that might cause weird behavior?”“No, no. I’ve just been optimizing the file-handles.”“Are you just using jargon to sound like you know what you’re talking about?”“No! I mean, I’ve just been optimizing how we manage our file-handles so that we don’t leave them open.”“Oh, that makes sense. Show me..”Proud of his clever solution, Bob showed him:
Error'd: Practice What You Preach
"I think Oracle might want to read one of their own books on how to use MySQL," writes Mike.
The ShaoLinux Monk
Looking at the resumé, Paul felt like they’d found the perfect person for their data warehouse project. The resumé had all the relevant qualifications and experience needed to make a remarkable ETL tool. Paul talked to the candidate, Brad, briefly during the interview process. “It says here that you’re proficient with Linux and have extensive database knowledge.”
Coded Smorgasbord: Efficient WTFery
Some horrible code is acres of awful, thousands of tortured lines of mess and horror. Some developers can compress their WTFs down into a handful of lines.For example, Zlatko was working with a Node.js developer who was big on unit tests. Unfortunately, that developer didn’t understand that you couldn’t write a synchronous test for an asynchronous method- the test will always pass.That’s why this code, buried in a callback, passed:
Barely Broken In
One day in winter, during that blissful dead stretch between Christmas and New Year’s, Chris was startled out of a deep sleep. He reached for his blaring cell phone, squinting at the painfully bright screen.
CodeSOD: Variables Everywhere, But Not a Stop to Think
SharePoint. What can you say about it? Among other things, it's designed to help you manage and present content. It's supposed to make things easy for you. If you want some customization, just write some code to do whatever and configure it to run at the appropriate time for the appropriate page(s).Of course, this leaves open the possibility that folks who may be something less than experts might author said customizations.Paul is responsible for numerous customizations written by developers long gone from their project. One particular customization was to perform some clean up. At first, it was run once per day. Over time, that grew to running 8+ times per day on each of several servers.One day, the customization stopped working. Naturally, there was no record of it anywhere in source control (thank you predecessor coders).Having no alternative, the code was decompiled into the following loveliness:
Error'd: An Interesting, Cryptic, and Artistic Error
"Proof that there's a poet living deep within each of us...even developers," Ed writes.
CodeSOD: Accurate Comments
Kevin L saw the program crash with a null pointer exception. This lead to digging through stack traces, logs, and eventually the commit history to figure out who was responsible.The code itself is a simple “string padding” function, the sort of thing that when people screw it up, you just have to wonder why. This variation on that theme, however, gives us that rare treat: an accurate comment that describes the function.
Getting Wired
It had been a very long weekend.On Friday, the CIO of Brendan’s company announced that something big was in order and details would be revealed Monday morning. Questions quietly circled around the office for the rest of that day. Were people getting laid off? Was a customer unhappy and withholding payment? Was the software division being sold to East Kerblekistan?…and many of these unanswered questions transmuted into rumors.Come Monday morning, the staff shuffled into the company’s largest conference room to hear the news. Andy, the CIO, showed up fifteen minutes late as usual. He had reached CIO status not by being punctual, smart, knowledgeable, or even particularly effective. Instead, his sharp dress, smooth tongue, and slick presentations got the job done. He had a bright can-do attitude, knew all the right buzzwords (and could occasionally string them together into something resembling a sentence), and anyone without a technical background (most importantly the CEO and the Board of Directors) saw him as a technical genius.Today Andy was positively beaming. This was far above and beyond his normal self-important pomp and arrogance. From his wide smile and ecstatic mood, Brendan half-expected him to whip out a Nobel Prize, or Turing Award, or Oscar, and self-congratulate in front of the entire IT staff.“Employees of Initech! I am proud to announce that we are finally moving into the 21st century!” Andy began. “I’ve spent the past several months in research and negotiations, and because of my hard work Initech has just been awarded a half million dollar federal grant to update our network to wireless technology! This will completely reinvigorate and synergize the company, and is a fundamental key to our plan for winning several high-dollar federal contracts for the fiscal year of 2005. Our commitment to technology is vital to our core business principles, and this upgrade will prove to prospective clients that we are serious about advancing the state of modern technology. When they tour this office and experience our brand-new wireless network, they will have no choice but to choose Initech for all of their needs!”At that point, Brendan sighed in relief and mentally checked out as Andy kept talking for the next 45 minutes about how great this network upgrade would be for business.Not long after, Andy announced a new Network Upgrade Task Force, which he would be personally overseeing, to plan and execute the upgrade. Brendan was tagged as a vital part of the team, with tasks right on the critical path.Initech already had a reliable wired network, and nobody was complaining about the lack of wireless access. Brendan tried to question why the network upgrade was even needed, but Carl, the team leader and one of the company’s domain administrators, pulled him aside and politely told him that questioning the CIO’s plans would be a career-ending error.Over the next several weeks the team of twelve developed a plan. They started simple, trying to provide wireless access to the few areas where it would make sense, but soon Andy interfered, demanding wireless access in the places that didn’t make sense. The plan became more and more complicated, resulting in dozens of wasted man-hours spent drawing up new hypothetical network diagrams. Eventually, it was decreed that Initech’s entire building, all 14 floors, would be covered by the new 802.11g-compliant wireless network. A wireless access point was to be installed in each room, and each workstation would be assigned a USB external Wi-Fi adapter. Each office room had between 5 and 30 workstations, depending on the team and duties.Outside of one of the planning meetings, Brendan pulled aside a few of his teammates. “We’re going to have over a thousand PCs all join the same wireless network? And have almost 150 wireless access points all within the same building? This is NOT going to work!”Carl shook his head in agreement. “We can’t fight Andy on this, remember what happened to Al and Gerald last year?” Brendan recalled: unemployment happened. “We just need to do the best we can. Andy’s set his mind on it, but if we can survive the beginning, we can quietly improve things once he moves on to The Next Great Project.”The project plan was completed and the other executives rubber-stamped it. On a Friday six weeks later, the Network Upgrade Task Force waited for the regular office staff to leave. They had until Monday morning to get everything set up.By noon on Sunday, every WAP had been installed and configured, Ethernet switches from each office were removed and placed in storage, and every desktop workstation had a shiny new USB adapter connected. Andy decided that full-scale testing was unnecessary, but he did allow them to connect a few random systems to the new wireless network for testing. The new network technically worked. With only a few PCs on at once typical throughput had dropped from 100 megabit to only 15 or 20, but they had wireless! Andy ordered the team to write a memo of instructions on how to join a PC to the network, and one was printed and distributed to each workstation in the building except for the few they’d set up themselves. The CIO declared the project a success and ordered pizza for the team in celebration.Monday did not go well for anyone on the upgrade team. Brendan personally spent nearly 16 hours that day connecting hundreds of workstations to the wireless network because the users were unable to follow the instructions correctly. As additional workstations were brought online, the network slowed to a crawl. Initech’s internal web sites and applications became unusable for most users, and throughput tests consistently returned kilobit rates which were barely double-digit, if they succeeded at all.Andy was absolutely furious and stormed through the building, red-faced, bellowing at the members of the upgrade team as they fought to connect workstations to the network. “What the hell is wrong with you people? This stuff was all working when we left yesterday! It was working! Find out what you did wrong and fix it! We HAVE to get the network working, contracts worth millions of dollars are on the line! Do you hear me?!” He stormed off, and the team managed to slip away to a distant conference room.“Alright, what are we going to do?” Carl said.“Can we go back to the old wired network and not tell Andy? Pretend we’re using wireless?” Brendan asked.Carl shook his head. “He may be an idiot, but he’s watching us too closely. We’ll all be gone if he finds out we aren’t actually using WiFi.”“There’s just too many wireless devices too close to each other,” responded Brendan. “I walked around the office with my personal laptop and a WiFi monitor. All the access points are channel-hopping like mad trying to find a clear channel. I can’t even connect unless I’m within a couple feet of an access point.”Alex, a quiet engineer from the hardware division, spoke up. “It works if you’re close to an access point?” Brendan nodded. “So what if we can get everyone that close?” Puzzled glances were exchanged. “Remember Project Sapphire from two years ago?” he added. “That government project Andy bought all the equipment for and then we didn’t win the contract? We still have several pallets full of USB extension cables from that!”The idea was crazy, but they decided to test it in a couple offices. They strung up USB extensions and relocated each workstation’s external WiFi adapter, situating them all within a foot or so of the nearest access point. And by golly it worked! Throughput was only a few megabits, but the connection was generally reliable!As they finished the first round of testing, Andy showed up, ready to chew the team out for not fixing the network yet. Carl explained that they had a possible workaround and his anger mellowed a bit. “As long as it’s working by tomorrow.” He huffed and stormed out.By eight o’clock the next morning, every single WiFi adapter in the building had been relocated. Bandwidth was limited to 2 - 3 Mbps due to contention, but at least network timeouts were rare. Despite the unsightly mess of WiFi adapters piled around each access point, Andy was pleased. “See, this is why I picked you guys, I knew you’d make it work! This is the kind of ingenuity that makes Initech the best in the industry! Good work! Get us through today, and you can all have tomorrow off.”By the end of the day, the team finished configuring the last remaining workstations and corrected a few relatively minor issues. The network was drastically slower than it used to be, but was “fast enough” for most of the staff. At the next full-staff quarterly meeting, Andy gave a forty-minute presentation about the resounding success and ROI of the network “upgrade”.Brendan rolled his eyes and decided to update his résumé in case he got involved in whatever Andy’s next scheme would be.[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
CodeSOD: Abuse of Properties
Every .NET programmer is familiar with the concept of properties. They’re a nice language feature, allowing the programmer to inject little bits of logic into the process of retrieving or setting the value of a field. A getter can, for example, lazily initialize a field when it’s first used, and a setter can validate the value before it’s set. Even a simple property with no logic beyond providing access to a backing field can be made useful by appearing in an interface or being overridden by a derived class.An important aspect of properties is that to the outside user, they appear almost no different from a regular field. As such, they’re supposed to behave like regular fields. Any visible side effects beyond what’s necessary are heavily frowned upon, and the developer who uses the property can reasonably expect it to provide transparent access to data from his point of view.KallDrexx’s coworker, however, was forced to deal with code made by people who didn’t seem to understand the “transparent” part– or, in fact, any part…
Tales from the Interview: Role Reversal
Ki and Morgan had an on-again, off-again relationship, but not because they couldn’t commit; Morgan was Ki’s dedicated recruitment agent at Impracticable Resources. Ki had to admit he left every other recruiter she’d dealt with in the dust. That’s why she was excited when he described the position at Initech: Ki had started as a web designer and migrated into Java development, and Initech was looking for exactly that to be the glue between their Java and UX teams. Eight short weeks ago, the initial phone screen had gone well.Gerard was Ki’s would-be boss’s name, and warned her straight away that Initech was procedure-friendly; every box on their list had to be ticked and accompanied by its own list of ticked box-ticking-assurance boxes, supplemented by a list of ticked box-ticking-assurance-box-ticking-assurance boxes before they could bring her on board.“I am very impressed by what I see,” Gerard said. “We want to bring you on-site, for our standard gauntlet of interviews. Sound good?”“Definitely,” Ki said. “When would you like me to come in?”“We’ll let you know,” Gerard said, “your recruiter will give you a call.”Morgan did give Ki a call, almost three weeks later.“Ki, how’ve you been?”“Good. Waiting to hear about the Initech position, I guess… You?”“Yeah, Initech. They seem really interested in you! Can you do Thursday afternoon?”Ki stumbled out of Initech’s offices two-and-a-half hours after her arrival, exhausted but happy. Her interviews had gone extremely well. Gerard, who was head of the Java team, Celia, head of the UX team, and Armin, the lead designer, all agreed that she was at the exact nexus of design and development acumen that the job required. On the phone that afternoon, Morgan glowed to the extent one can glow via audio.“Ki, the job’s as good as yours!”“That’s great! Did they send you an offer?”“Well… no. Knowing Initech, they’ll need you to come in again for a second battery of interviews. I’ll give you a call when they’ve been in touch.”So that was that, for another three weeks.“Good news, Ki!”“You’ve got a lead on a company that hasn’t outsourced their hiring to a glacier?”“Even better: Initech wants you to come in next Tuesday. Now, for this set you’re going to need a portfolio of previous work. You met Armin and Celia last time? Well, they’ll be grilling you on your presentation. That’s why I’m giving you all this notice!”Ki looked at the past weeks sitting long and empty on her desktop calendar. “Uh, thanks.”Gerard, Celia, and Armin were all glad to see Ki again, and somehow (perhaps because they had three weeks to prepare) they each had almost an hour of questions for her before her portfolio presentation. But she passed with flying colours and, on the brief tour of the office, Gerard apologized for the amount of time the whole process was taking. “If it were up to me,” he said, “you’d start tomorrow. But HR still wants to have a word with you, and the whole team is headed out West for the annual general meeting at Initech HQ. I’ll be sure to put in a good word for you with the bigwigs out there!”Ki thanked Gerard and left. Soon after, she called Morgan.“So Gerard tells me good things!”“Yes, they seemed happy with me… again. But apparently there’s one more interview—did they mention when they’d be back from their visit to HQ?”“Let me see… oh, yes, here’s Gerard’s email. Looks like you’ll be sitting down with HR on… hmm… uh, June 9th.”“That’s two weeks from now.”“Sure looks that way! Sorry, Ki. But this is going to be awesome once we’ve crossed the Ts and dotted the lowercase Js!”And so Ki found herself up late on the night of June 10, having heard nothing from Morgan, Gerard, or Initech’s HR department. She was turning her mobile over and over in her hand, weighing her need to know against the possibility that Morgan, on the East Coast, would be asleep by now.“Hell with it,” she told herself, “if he didn’t want midnight phone calls, he should’ve gone into used-car sales.”“H-Hello?” Morgan sounded groggy, but Ki held firm.“Hi Morgan, it’s Ki. I’m sorry to call so late, but I haven’t heard from Initech, and I’m wondering if they got in touch with you. I’m sure you understand that, after eight weeks, I really need to get some closure.”There was a long pause on the other end, followed by a deep sigh. “…Ki, it’s… complicated. Really, I don’t know how this happened.”There was that sinking feeling, the one that starts in your stomach and descends to places unmentionable. “How what happened, Morgan?”"Well, I’ve got this email here from Initech HR. Apparently, in the wake of their annual general meeting at Initech HQ, it was decided that the role you’re applying for would be better suited to a less-technical candidate. I don’t know if they mean someone who just does web design, or what.“I’m really sorry about this, Ki. It sounds like you’re out of the running.”“I don’t understand,” Ki said. “You’re saying they changed the job so I’m no longer a shoe-in?”“I suppose that’s what I’m saying. Yes.”“Well… okay. I’m sorry to hear that. Goodnight, I guess?”“Goodnight, Ki…”“Oh, Morgan?”“Yes?”“Try to find me a position in computer vision or compiler design next, okay?”“Huh?”“That way, when they downgrade the position, I’ll be a perfect fit.”“Goodnight, Ki.”[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
Announcements: London and Amsterdam TDWTF Meet-ups
I'll be in London this week (Thus Feb 12) and Amsterdam next (Tues Feb 17), and thought it'd be a perfect opportunity for another The Daily WTF meet-up. Here's a pic from a previous year's London meet-up:
Error'd: Vacuums and Prints 20 Pages Per Minute!
"At first, I was a little skeptical about buying a 3rd party battery, but after looking at the extra features, I'm sold!" writes Emily S..
Representative Line: How to Validate a URL
There's an old joke among programmers, particularly those who have had to use regexes more often than they're comfortable with:
To Spite Your Face…
“I’ve got a gig for you,” said the recruiter.Clive, like many freelancers, weighed the contents of his bank account versus the daily rate he was promised, and decided that any gig was for him under those conditions. This one sounded mostly okay; an insurance company needed a new software package that would help them leap through some regulatory hoops. As a bonus, they wanted someone who could teach their devs the latest tools and techniques… like source control. Clive aced the interview, and started a week later. There was already an email waiting in his work inbox, from someone named Brandon. It read: “See me.”That nose won't know what hit it…Brandon lurked in his office, adhered to his mid–90s ergonomic chair like it was an appendage. He glared over his monitor and stared at Clive. “You work for me,” he said.In monosyllables and four word sentences, Brandon revealed that no one who participated in the hiring decision would have any day-to-day contact with Clive. Clive reported to him, and him alone.“Okay… well, when I was hired, they said that they wanted me to set up Subversion. Should I get started on that?” Clive asked.“No.”“May I ask why? Do you have another preference? Would you like to discuss the options?”“No.”Clive waited. Brandon didn’t expand. He simply stared at Clive. Stared, and stared.Clive slunk back to his cube and got started on looking at the code base. It currently lived in a file share, using the “file.pl.old”, “file.pl.old.old” versioning convention. The code was Perl, and unreadable by even Perl standards. It had grown in a culture here “parsable means runnable”, included no comments, and had absolutely no tests. Clive’s only ally was Lee, another head-hunted expert who also reported directly to Brandon, and had a two week head start on understanding the code. When Clive got stuck, he poked his head around the cube wall and asked Lee.Like a glacier grinding down a mountain, Clive slowly worked his way through the code. After about a week, he was developing a small degree of confidence. Then an email from Brandon arrived: “See me.”“You’re disrupting the dev team,” he said.“What?”“You and Lee are making too much noise. This is an office, not a social club.”“That’s crazy. I’m just asking him questions about the work we’re doing! What, do you want us to schedule a conference room just to ask questions?”“Yes.”Brandon stopped talking and resumed his staring contest. He stared, and stared… Clive got the point and scurried back to his cube.The requirements were complex and evolving, which wasn’t unusual. Only one user, Carole, actually knew what they were, which also wasn’t unusual. Clive sent her an email with a handful of questions, and tried to get some work done. He waited for a few days for her reply, and as he found new questions, he sent more emails.In a week, he had sent nearly half a dozen, but got no reply. He sent more, asking for status updates. Over this time, he had more questions. He tried calling her, but it dumped to a full voicemail box. He tried scheduling a meeting, but Carole never accepted.And then an email from Brandon arrived: “See me.”“Carole says you’re harassing her,” Brandon said.“What?”“You send her emails, even after she answers your questions. She said you called a meeting but didn’t show up for it. This needs to stop.”“That’s crazy. She never replied, and I can show you my inbox to prove it.”“Carole doesn’t use email,” Brandon explained. “An intern prints out her emails, and she replies via inter-office mail. She’s very busy. You have the requirements document. Implement it, and stop bothering her.”“What, you want us to implement a solution without ever talking to the business user who knows the requirements?”Brandon stared at him. And stared. And…With Lee’s help, Clive made some real progress over the next few months. They learned their way around the absurd date format (measured as the number of days since April 3rd, 1974, except when it was measured in the number of months since the preceding Monday, except when it was measured in the number of weeks since the following Sunday). They worked past the fact that no one was allowed to upgrade past Firefox 3, or the fact that they couldn’t run overnight jobs because all of the servers were turned off at 6PM sharp. Carole didn’t communicate, Brandon just stared at them, and the rest of their co-workers treated them like plague carriers.A few weeks before their six month stint expired, Clive was digging through the company network drive, searching for a spreadsheet containing sample data. He found one named after the recruiting company that placed him, and hoped that it was something useful. It was, after a fashion.The spreadsheet was a report illustrating exactly how much the recruiting company was getting paid to provide Clive and Lee. The fees were so abusive a used car salesman would have blushed. Change tracking and collaboration was enabled on the document, which meant Clive could read comments made by various users.From the senior management level, there were comments like, “It doesn’t matter how expensive it is.” Accounting warned, “We won’t have the money to pay annual bonuses, if we do this!”Brandon had left his own note: “Our business is too special. They will fail. This is a waste of money. They will fail.”The pieces clicked into place. Brandon hadn’t been making a prediction; he was making a promise. And he’d kept it- there was no way that Clive and Lee could deliver what was originally promised in the next few weeks.Then an email from their recruiter arrived. “That company still wants added staff. Do you want to re-up for another six months?”Having learned from Brandon, Clive sent a one-word reply: “No.”[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
CodeSOD: Head in the Tag Cloud
When most folks create something, be it carved, welded or coded, they take pride in what they're creating. It's a reflection of their soul. It's personal. They care.However, once you tell someone that their stuff will be in or on something that is someone else's responsibility (aka.: problem), they often take less care in what they're putting there.To me, the phrase The Cloud can be safely replaced with Someone Else's Computer in every conceivable context; load-distribution; storage; file transfer; etc.As such, all too often, when something is to be in/near/on/associated-with any-or-all-things-cloud, the folks who build it tend to do somewhat lower quality work.Ayken recently inherited an old website that quickly turned out to be a management nightmare. Every veteran who is used to fighting such ancient demons knows that every PHP project comes with ridiculous stuff like this trim-function that was clearly written in complete ignorance of the existence of regular expressions:
...5455565758