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
Announcements: Sponsor Announcement: Scout
Our sponsorship program has been a great success, and we’ve got another great sponsor to help us keep this site running and bring you the horrors that your jaded eyes crave, along with special features like TDWTF Live and our recent BYOC contest about the Lucky Deuce. Our newest sponsor is Scout. They donate $10 to the Larimer County Humane Society every time somebody tries out Scout, and now they’re launching a new tool…Founded in 2009, Scout has been delivering SaaS based server monitoring software for over 6 years. With StatsD & AWS support, Scout Server Monitoring has been the clean, reliable alternative to expensive build-your-own monitoring solutions.Now, due to overwhelming customer demand for a fresh approach to APM, Scout has built a cloud-based / SaaS Application Performance Management tool for critical web applications. Dominant SaaS APM solutions (e.g. New Relic) are almost a decade old. Scout APM is a fresh take with modern, streamlined interface and unmatched capabilities.Scout APM provides deep metrics, analysis and solutions for performance problems in production web application. For developers, Scout APM is the fastest path from performance nightmares to the specific line-of-code. With built-in git integration, Scout APM can even identify the specific developer who can solve the problem based on code commit history.For managers and business owners, Scout APM prioritizes slow performance according to business impact. Scout APM allows customers to add context to find out who is affected most by slow performance.Find out more at: apm.scoutapp.com, or if you’re in Las Vegas for AWS re:Invent 2015 stop in at booth #1130. Be sure to ask about the Oculus Rift give-away[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: Not So Unique
When designing a database schema, it's often important to assign a unique identifier to each record. Such surrogate keys almost always make querying for data both simpler and faster, and the overhead of an additional column is usually a cost worth paying. As such, nearly all databases provide some means of generating such identifiers, either in form of sequential numbers, or more fancy UUID schemes.As is often the case at The Daily WTF, however, many developers prefer to reinvent the wheel. Today's code came to light when our Anonymous submitter—a mid-level programmer maintaining the codebase written by a team of senior developers and highly paid consultants—was tasked with investigating a failing bulk import from an external system. The procedure didn't throw any errors, but for some reason only half of the 12 million records ended up inserted into the database.Digging through the code, he finally found the source of all his problems:
Dual Helix
Bruce B., a recent high school graduate in need of a job, thought it was a good opportunity. A friend had set him up with a job at a one-man development shop. His new boss, Louis, would provide on-the-job training, and it paid well for an entry-level position.Louis met Bruce at the former’s house and led him to a basement office. “Your friend told me a lot about you, Bruce,” Louis said. He had a smile like Jack Torrance from The Shining. “Is it true you can already program?”“Oh, sure,” Bruce said. “I’ve been coding C# for a while now. I’ve learned how to use classes and interfaces–”“C#? What a useless language.” Louis waved his hand. “I’ve got the real deal.”Louis led Bruce an Apple LC. On the screen were displayed rounded rectangles, with labels such as “Unique” and “If/Then/Else”, linked together by arrows. It was as if someone had created a flowchart using children’s wooden letter blocks.“Helix,” Louis announced. “The pinnacle in computer programming languages.”A Normalized GenomeDouble Helix, Louis explained, was the most advanced version of a series of database management systems, using a fully-graphical programming language for its procedural code. Introduced early in the 1980s, Helix became a niche product by the end of the decade, overtaken by dbase and other, less GUI-reliant relational databases.“I’ll give you an ebook that will teach you the language,” Louis said. He stared longingly at the screen. “It’s truly a magnificent piece of software.”Bruce shook off the cultish feeling that afternoon before reading Louis’s email. He had attached a PDF of Riding the Helix Express. Bruce stayed up all night, reading it in morbid fascination.The next day he mentioned a passage on normalization to Louis. “The book doesn’t go into much detail. What do you use for normalization?”“What? Forget that.” Louis waved his arms around. “In fact, delete that book. It’s no good. Helix doesn’t need old-fashioned normalization. It has its own way of normalizing data.”Bruce didn’t remember that part from Riding the Helix Express, but Louis had already moved on. He put Bruce to work correcting some records in a car dealership’s database.Flowchart DNANone of the data, Bruce discovered, had been normalized. Salespeople would routinely mistype IDs and other fields, filling the database with mismatched data. In fact, there was no validation on any fields. As Bruce worked on other databases Louis had created, he found similar data integrity issues.Louis’s Helix code, which Bruce routinely had to troubleshoot, was worse. Those block-like flowcharts were much harder to follow than a regular, typed programming language, exacerbated by Louis’s spaghetti coding patterns. Fixing it was like untangling Christmas lights.But the money was good, so Bruce kept coming into work.Meanwhile, Louis showed growing disappointment in his new hire. “Bruce, I don’t know why I put up with you. You’re always critizing my work, you don’t follow my advice, and I’ve seen you reading that ebook I told you to delete. I really need you to shape up, or I’ll have to let you go.”Unwound HelixOne day, Bruce arrived in the basement to find Louis in a huff.“I’ve put up with your shenanigans all summer, Bruce. ‘Normalization,’ ‘indexing,’ it’s just one excuse after another with you!” He pointed at his screen. “Now, this procedure isn’t working. Show me you’re still capable of doing this job.”Bruce sighed, sat at his computer, and tried to make sense of Louis’s code. It was the worst tangle that he had seen since he started working for Louis. Worse, Bruce had skipped his coffee that morning, leaving him unable to concentrate.“I don’t think I–”“Gaaah!” Louis pushed Bruce aside and sat himself in front of the computer. He started playing with the blocks, teasing apart the code. Bruce, sitting nearby, watched in silence, listening to the clock ticking on the wall, the click-click of the mouse, Louis’s little groans of frustration. The Helix code swam in front of his eyes, filling the room, enveloping him–Bruce woke just before he hit the floor. He had fallen asleep and slipped out of his chair.Louis, caught up in his work, hadn’t even noticed.As his boss continued to untangle his own Helix code, Bruce quietly wrote a resignation note and left it on his desk. In his opinion, Double Helix should never have left the 1980s.[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 Most Pessimistic Search
Sometimes here at TDWTF, we get code snippets that are immediately obvious in their wrongness. But sometimes, the code only looks mildly inefficient, and it's up to the submitter to let us know how bad it actually is.Take the following snippet:
Eins, Zwei, Zuffa!
Dave had been at Initech for a few years, and things were looking pretty good. Everyone was working towards a big project launch, and every team was on target, on schedule, and on budget. The management, however, was not confident, and decided to “increase quality”. Their solution was to bring in two experienced, highly-paid consultants from the land of engineering excellence: Germany.The two consultants were Bob Schlüdell and Bob Gepäckträger. They became known as Bob Eins and Bob Zwei. They assessed the situation, then rolled up their sleeves and started hacking on all of the projects and code bases with their special skills.And how special those skills were.Bob Eins had two favorite things: C++ templates and threads. Anything that used both of these was good, and everything that did not was garbage and had to be rewritten to use threading and templates. He would take whatever library the company was using, reimplement about half of it with layer upon layer of templated classes, and inform the team that, “You will use this from now on!” Then he would start working on a new library and abandon the previous one, meaning that all of his code was unmaintained.Bob Zwei was a different kind of beast. At his previous job, he had worked on some project codenamed “Volcano”, and that was all he ever wanted to talk about. Ask him any question from, “Have you seen this compiler error before?” to “Hey, we’re all going out to lunch today, wanna come?”, and he’d respond with, “You know, back when I was working on Project Volcano…” followed by twenty minutes of chatter about design problems completely irrelevant to the initial topic of discussion.Dave managed to keep under the radar of the Bobs for awhile, but eventually they found him. They gave him a new core library to use. He sighed and went back to work. How bad could it be?It was much, much worse than he could possibly imagine. The first thing he learned was that these two Germans were very organized. Majorly, pedantically, obsessive-compulsively organized. Even the most uptight librarian would tell them to loosen up. Due to this, the Bobs demanded that everyone follow strict namespacing standards to keep code organized. However, each of the Bobs had their own radically different scheme.For example, a network socket class implemented by Bob Eins– because socket.h was Not Invented Here, and thus not good enough– was namespaced as base::universe::posix::network::socket::Constants::IPV4. It was unclear what existed outside of the base::universe namespace. Meanwhile, Bob Swei organized all his classes along the convention com::initech::divisionname::projectname::objectname, and refused to accept the reality that some projects spanned divisions, and thus couldn’t be slotted into that hierarchy.This was all somewhat manageable until Bob Eins dropped the biggest bomb. His NIH-itis flared up again, so he wrote his very own signal/slot mechanism. All existing code needed to be converted away from Qt’s perfectly usable mechanism as soon as possible. The unique feature of Bob’s version was that everything was a thread. Every service? Thread. Every operation? Thread. Every object? Thread. Every method call? Thread. Everything. This would, it was gloriously announced, get rid of the bottleneck of having a single event loop running on the main thread.Bob Eins answered every objection raised by the other developers with a variation of, “That is not an issue!” No reasoning was ever given. Future maintenance costs were “Not an issue!” Throwing away a year’s worth of working code was “Not an issue!” The massive amount of threading bugs, resource contention, and overhead were “Not an issue!”Bob Zwei answered every objection raised by the other developers with a variation of, “You know, back when I was working on Project Volcano…”All work ground to a halt. Because of the liberal use of templates, the project’s compile speed would have brought ridicule from a severely asthmatic snail. A “Hello World” for their framework took two minutes to compile. The full suite could take hours. Most developer time not wasted waiting for the compiler was spent adding mutexes everywhere, since you could no longer rely on any variable not magically changing out from under you. And the rest of their time was spent debugging race conditions, deadlocks, and resource leaks.Eventually, the Bobs stepped in with a new solution: every object in every thread would run its own personal event loop.Nothing was getting done, and management started getting anxious. One morning, Dave’s cube-mate was grabbed from his multiple week stint of fixing threading bugs into a meeting and shouted at for what seemed like forever. Dave could hear the muffled shouts. “Because your component isn’t finished, you are personally jeopardizing the future of the entire company!”After a particularly fruitless bug hunt, Dave had no idea what could be causing his race conditions, so he figured he’d ask Bob Eins. He described his problem. Herr Eins glanced at his code for a microsecond and said, “There is nothing wrong in the platform. You are just using it incorrectly.”“Is there any documentation on how to do this correctly?”“There is no need for documentation. Just read the source code,” Bob Eins replied. He waved a hand and wandered off to do more template metaprogramming.Dave went to Bob Zwei next. “You know,” he began, “back when I was working on Project Volcano…”Dave didn’t want to look at the library sources, for they used every possible C++ misfeature and were as impenetrable as Mirkwood. After battling the digital equivalents of spiders and elves in a dense thicket of intertwined templates, he finally found what he was looking for: a helper class for the signal system. It was unusual, in that it had a comment, possibly the only one in the entirety of the Bobs’ code. It looked like this:
Error'd: Adult Supervision Required
"I was found that my NAS was choking on small files," Lionel S. writes, "Now I know it was a marble all along."
CodeSOD: A Handle on Events
As developers, we try to write software that will be helpful to our users. Sometimes, we'll do key-by-key examination of what they're typing to do auto-complete. Sometimes, we'll look at a type-field entry to display the relevant subset of subordinate fields to be entered. Sometimes, we'll even try to coalesce error messages so that the user gets one message with a list of mistakes as opposed to one message per mistake.Of course, it helps if the logic to detect multiple errors and coalesce them into one is correct.Mike M. was supporting a system that had an event queue. In the case of this particular queue, the messages were all for the same condition. To be helpful, the cow-orker who wrote it decided to only display the pop-up for the first message in the queue and silently swallow the rest.For the longest time, the system generated a single message for the given condition and so only a single pop-up was ever displayed.Recently, something unrelated changed, and the system started generating a large number of identical events at once on the queue, which exposed a flaw in the coalescing logic; it took Mike four minutes of continuous clicking to get through the queue of event messages:
Editor's Soapbox: Processing a Rant
In addition to being your intrepid editor, I’m an independent consultant. People hire consultants because they want someone to “inform their process”. “How do we do Agile better? Do we do Scrum or Kanban? Can we do scrumfall instead?” “Should we do BDD, TDD, or ATDD? Or combine them? Are there any other acronyms we should be doing?”
CodeSOD: MacGyver's XMLHTTPRequest
In these days of browser standards, it’s easy to forget that once upon a time, simple tasks like an HTTP request from JavaScript were difficult or even impossible, and if you wanted it to work in every browser, you were going to have to write wrappers to try and create a consistent API.Zeke inherited an application back from those bad old days. It needs to poll a server, and based on the response, it performs an action, but it does this in an “inventive” way.First, they fashion a rudimentary enum:
Announcements: Release! at Ohio Linux Fest
To introduce myself, that’s me over in the right corner. Hi. You might remember that, a year or so back, this site got a face lift. We still love the way it looks, but, if we are being straight with you, the CSS and HTML are a damn mess. So, I’ll be re-building the site while maintaining the same look, and maybe writing an article here and there.Most of you are familiar with Release!, the card game, which Inedo came out with last summer. The support on Kickstarter was fantastic, especially from the Daily WTF community. I was the lead game designer on Release!, and I was also on the team for our more recent Kickstarter campaign, ABC++.This October, I am pleased to participate in an event in my town: Ohio Linux Fest in Columbus will feature Release! during its game nights, and give me the opportunity to speak about the overlap of game and software design.Catch my talk, Pinochle, Dungeons and Dragons, and Software Usability, as well as some Release! demos during Friday’s happy hour, and at the afterparty.The talk revolves around how board games utilize a very similar design infrastructure as software UIs to communicate with their users. It mostly discusses the lessons we can take from these cardboard interfaces and how to apply them to digital ones.God, that sounds nerdy as hell.Anyway, I will be sure to bring some TDWTF Mugs, and copies of Release! with me too. So, if you don’t have the game yet you might wind up scoring a free pack![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!
You're Not My MIME Type
Andrew performed corporate support for a giant multinational. One day, he was assigned what looked like a straightforward bug: a new Intranet webpage for one business unit was failing to accept CSV spreadsheets containing product information from another business unit.After obtaining the proper permissions, Andrew first attempted to duplicate the issue. He browsed to the Intranet upload page, then tried to upload the user’s example CSV files. Each attempt failed with the oh-so-helpful message “Invalid file type.”Well, they were perfectly valid CSV files. Andrew tracked down the developer support contact for the site—Brian—and forwarded him the ticket.Not an hour later, the ticket boomeranged right back to Andrew, with a note from Brian attached. The code that handles file uploads is a third-party library. You’ll have to contact them for help.Ugh. The very thought set Andrew’s teeth on edge. First, he decided to see if there was the slightest chance of resolving the error himself. He googled every search string combination he could think of for the library name, error, scenario—no dice. The company website offered no useful documentation, either. It had support forums, but they were ghost towns.Andrew’s dread amplified. Realistically, this wasn’t going to get fully resolved before the heat death of the universe. That whole time, Andrew was sure to have users breathing down his neck. His next effort was to get a workaround in place. After making several phone calls and painfully backtracking his way to the people in charge of the dual business unit venture (“Tiffany? Oh, she doesn’t even work here anymore. You want Rob!”), he arranged things so that his users could email their CSV files directly to one person in the other business unit.These herculean efforts garnered Andrew nothing but huffy scorn. “This is really inconvenient for us,” nagged the user who’d logged the ticket.“It’s the best we can do until we get this third-party code fixed,” Andrew replied, taking it in stride.Well, he’d done what he could. It was time to give third-party support a call. After navigating an extensive phone tree, he had a (presumed) live specimen on the other end to whom he could explain the issue.“So why’s this happening?” he asked.“That doesn’t sound familiar,” Carl, the rep on the other side, told him. “We’ll have to try to duplicate the issue on our end. Do you have some of these files?”“Yes, I can email them to you,” Andrew said.“Great! We’ll test that out and let you know what we find.”To his credit, Carl called back within a few days to notify Andrew that the behavior had been duplicated. However, he didn’t know what was going wrong either, and would have to escalate the ticket on his end.A few weeks later, Andrew received another call from Carl. “All right, this is admittedly a strange case. Let me explain. To determine a valid file type, our code checks and ensures that the MIME type of an uploaded file matches the known MIME types associated with the file extension. It does this by looking at the beginning of the file and following some rules of thumb.”“OK,” Andrew said, furiously scribbling all this down in a notebook for future reference.“It’s a safety feature,” Carl said. “Looking at your example files, they all begin with entries that start with C, then a space.”“Yeah,” Andrew confirmed. “Those are part numbers.”“Well, back in the days of punch cards, FORTRAN programs indicated comment lines by punching a ‘C’ character in the first column, usually followed by a space.”Andrew froze for a few seconds. “Wait—so your code sees our part numbers and concludes the file is a FORTRAN program?”“I’m afraid so,” Carl said. “It’s working as designed.”“Working as designed?! It’s not flipping working at all!” Andrew cried.“This is expected behavior given your input,” Carl said. “You can edit your CSV files to not start with C-space values, or modify your logic around our library so that—”“No, I can’t do either of those things!” Andrew cut him off. “The users aren’t gonna change their files, and I have no access to the code! Couldn’t you edit the library to not make that check, and just be happy with a .csv file extension?”“We’re not prepared to do that at this time, but we can file a feature request.” In other words, Sorry, buddy. Your company doesn’t spend enough money with our company.“Fine,” Andrew growled, then hung up the phone. He pulled up his original support ticket to add this information and escalate it back to Brian, wondering how many minutes it would take to get kicked back with another blasé retort. As always, thanks for reading! If you like my articles, you might just love my new sci-fi/fantasy adventure novel about a knight who travels the galaxy with a starship, going on quests and getting into mischief. It has no WTFs in it (intentionally anyway), but hopefully the sword-fighting and deadly court intrigue make up for that. Enjoy! -Ellis[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!
Error'd: The Little Application That Couldn't
"I don't know what it was trying to do, but it just couldn't do it," Bert writes, "It also looks like it couldn't finish the error message."
CodeSOD: Sorting Cabinets
Sorting. It’s a well-studied class of problem, with a number of well-understood solutions. These days, pretty much any time you need to sort a collection, there’s a language-or-framework-provided function that handles it for you. Sure, a Better Idiot™ might try and implement their own sorting algorithm from scratch, but your Regular Idiot™ just has to call .sort- it’s Idiot Proof™, rightWell, David S. found a better idiot.
Registered Students
Tim C. took pride in his work. He debugged Clockaburra, a timetabling and management suite, used in Australian high schools. Oftentimes, it was a simple problem that could be reproduced after a quick phone call from a client- usually a vice principal or the secretary. It’s when a bug can’t be reproduced that things get tricky, but Tim had the solution for that as well.One day, he got a call shortly after lunch from a Mrs. Harriet, the vice principal of Charles Perkins High School. “All of our mathematics classes have disappeared from the schedule,” she said. “It just happened this morning.”“What was the last thing anyone did to the schedule before the error?”“Oh, I wouldn’t know,” Mrs. Harriet said. “There’s a few of us who use it. It could have been anything, really.”This was, of course, the worst-case scenario. Tim had to go with Plan B. “Okay, I’m going to need part of your registry tree.”Step-by-StepStandard procedure of quality assurance is to recreate the reported environment as closely as possible, then isolate all the variables which could cause the issue until you find the root cause. Due to Clockaburra’s architecture, the easiest way of recreating the user’s environment on his machine was to get the client to send him the registry tree for Clockaburra in a .res file.“Oh, I’m not sure I could do that,” she replied. “I wouldn’t know how.”“Oh, it’s easy,” Tim said. “I’ll walk you through it.” Although it nearly broke his stress ball, he managed to guide Mrs. Harriet through the process. Then he walked her through attaching the file to an email, which was a bit of a puzzle for her. The email arrived, titled, “VERY IMPORTANT FILE”, with a .res file attached. The file was a surprisingly large 5MB, but Tim assumed they must just have an unusual installation on their end. He updated his registry with that file and rebooted.Identity CrisisTim blinked. His screen displayed a login that read Charles Perkins High School. Above that was an image of Charles Perkins in his football kit. He tried his credentials and was met with an “Invalid Username” error.His phone rang. It was Mrs. Harriet, who was eager to get all of those mathematics classes back on the schedule.He laughed nervously. “It’s… uh… well underway,” he said. “I’ll get back to you with a full report once we have it fixed.”Things not well underway, it was his turn to call his tech support, Bennelong.“This is a first for me,” BEnnelong said, after taking one look at Tim’s new login screen. “What did you do last?”“I was updating my registry with one a client sent. She sent me the tree for Clockaburra which shouldn’t have-”Tim remembered that the .res file Mrs. Harriet had sent was a chunky 5MB. She had sent her entire computer’s registry, not just for Clockaburra. His computer was tricked into thinking it was hers.Academic DiscretionBennelong used System Restore to get Tim’s system back to just before the call with Mrs. Harriet. Tim isolated the Clockaburra registry tree in the file, and soon pinpointed the issue as some invalid settings. Mrs. Harriet- or someone else- had blindly mis-configured the application in the most creative way Tim had seen yet. He returned Mrs. Harriet’s phone call late that afternoon with instructions on how to fix the problem.“That took quite awhile,” she said. “Nothing serious, was it?”“It was more of a snafu on my end,” Tim admitted. “I actually had to call tech support to get me out of a jam. I’m very sorry for the delay.”“Well, I won’t tell if you won’t,” Mrs. Harriet said. “We all have our moments.”[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: The Coercive Types
Loosely typed languages may offer certain advantages in terms of ease of use and flexibility, but they bring another challenge: it’s difficult to know what it is you’re looking at. With no compiler type checking, it’s hard to compare two things, and that becomes extremely problematic when you’re working with languages like, say, JavaScript.Ruby, in its quest to “make programmers happy”, took a simplistic approach to the Truthy vs. Falsy problem. False is false. Nil is false. Everything else is True. Ruby is often used by web developers, who may be more comfortable in languages like JavaScript and PHP.That is presumably why Lisa found this debacle in her code base, placed there by a co-worker who preferred other web languages:
The Graduate
Management will frequently hire young developers just out of school because a) they're cheap, and b) a developer is a developer is a developer. Graduates, especially from advanced degree programs, always have more advanced training than those with lesser degrees, and should be able to bring advanced skills to the table on day-1. Sometimes management gets lucky, and with a bit of proper guidance and oversight, the newbie can create something reasonably functional, performant and maintainable. This is not one of those occasions.In the aftermath of that strategy when management realizes that perhaps something is amiss and the usual threats of get it done don't seem to work, management crowbars open the purse strings and highly paid consultants are often sought after to clean up the mess. Sometimes the consultant can fix the mess. Sometimes the power of management to $*#%& up a project far outstrips anyone's ability to fix it.Jenny was lured hired to make some minor modifications to speed up a system of the latter variety that was written by an unsupervised fresh-out. It was way over budget, behind schedule, full of bugs and not feature-complete. The customers were not happy campers, and were not bashful about expressing their outrage dismay at the cost and progress. Basically, just another day in the office for Jenny.The application itself was run-of-the-mill case management software, storing basic demographic information about clients, the people that referred them and the history of their cases. It's a SQL Server database with ASP.NET forms to interact with the data. It should have been pretty simple stuff. Except...The design documents were literally coffee-stained napkins and Jenny was forewarned not to discard them. There had never been a DBA on the project. Naturally, this led Jenny down the rabbit hole...One of the first things she encountered everywhere was that columns that stored Yes/No data were declared as VARCHAR(20), and stored the literal strings "Yes", "No" and a variety of things that conjured up nightmares of FILE_NOT_FOUND.The application also had a number of data fields where the user must select a value from a pre-determined list, and the list is stored in the database. That is, there is a list of Suburbs, a list of PostCodes, a list of Illness types, etc. Rather than have tables called Suburbs, PostCodes and Illnesses, the developer opted for one table for all of them (interestingly, the booleans were not stored here, and commanded their own dedicated table). The table is called RefData_5, and whenever you want the data for any list (e.g.: the list of suburbs) you have to select from that single reference table and filter to get the records where RefType is "Suburb"). To complicate things, the table contained constant string values, numeric postal codes and enumerated values. Thus, once you queried the data, you needed to explicitly convert it to the correct type before you could use it.Of course, prior versions of the table still existed: RefData_4, RefData_3, RefData2 and RefData_1. Unfortunately, they weren't just there as unreferenced remnants. Some of them were referenced here and there throughout the code base and stored procedures, which led to all sorts of instability as table definitions changed over time.Adding to the woes, the code was not stored in any source control system; Jenny was handed the good copy on a USB key.Just to make things interesting, once a constant had been identified as applying to a particular situation, the PK of that constant record was not stored in the foreign record. Instead, the constant literal and the single character key (e.g.: "12345" and "P"ostcode) were stored. Of course, you had to ensure that you never used the same key for two different data types in the REF_DATA_n table, or going the other way might become an interesting challenge.Perhaps most impressive, is that the graduate managed to write queries on this structure. They were hundreds of lines of T-SQL if-else's and ran, well, glacially, and mostly returned the correct data. Mostly. So now Jenny gets to explain to management why their system that was inexpensively developed by the graduate ran so slowly and inconsistently, could not simply be tweaked to make it faster, and that a full rewrite was in order; all to hear in return: you're a highly paid consultant and you can't fix it?! Why are we paying you?[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!
Error'd: Blah, blah, blah!
"Believe it or not, I've actually seen less helpful content on StackOverflow," Luc F. writes.
Power Trip
It was a hot, cloudless summer day outside the headquarters of SmallTown SoftCorp. That didn’t matter much to Neil though, as he basked in the frosty air conditioning of the company’s modest, self-owned building. During the building’sconstruction, Neil oversaw the installation of everything from the demarc to the HVAC system. This made him feel like he had a hand in the arctic clime of the office.Those nice cool thoughts were torched when the power in the whole office suddenly went out. A chorus of profanity could be heard as all of the developers who hadn’t saved their work in a while lost everything. People began to stumble out of the windowless meeting rooms that had become blackened employee traps. “What the hell is going on?!” Jack, SmallTown SoftCorp’s owner, bellowed from his dim office. Jack slowly felt his way to Neil’s desk. “Neil! You know how this building is wired better than anyone! Get the power back on NOW!” Jack commanded, sweat beginning to form on his brow without the air conditioner combating the heat.Neil had to bite back an “I told you so!” During the construction, Neil stressed the importance of a backup diesel generator, but Jack shot it down as an “unnecessary luxury”. Thankfully, he was allowed to purchase UPS’s to keep their mission-critical servers alive. Neil got out his cell and phoned the utility company. The automated voice was happy to tell him there were no outages in the area. He deduced the problem must be isolated to their building.Neil grabbed a flashlight and headed to the pitch-black bowels of the building. He flipped the main breaker on and everything in the office sprung back to life. “Easy enough,” he said to himself. But the real problem would be figuring out why this happened. He looked around, all the wiring seemed to be intact. There were no signs of a cooked mouse that bit down on the wrong cord. He decided to check with everyone around the office to see if they noticed anything strange.He got several stock “I was working hard and everything went black!” responses. Jack said he was on an important call with a customer, but a check of his internet logs would probably show he was wasting time on Twitter again. As Neil approached Mike, one of their framework developers, he got visibly flustered. “Hey Mike. Did you notice anything happening before the power went out?”“What? Me? No! Of course not! Why would a lowly programmer as myself know anything about a power outage?” Mike replied with a nervous chuckle. “It sure is cold in here though! My cubicle feels like an igloo.”Neil looked up and noticed Mike’s desk was directly under an air conditioning vent. “Ouch, looks like you got the cold spot! Try to think warm thoughts.”Neil went back to Jack’s office to report the bad news that he didn’t have a root cause for the outage. Jack used his electrical knowledge (or lack thereof) to determine the air conditioning must be sucking too much juice on a hot day. “Turn the AC down immediately, Neil! We can’t have this happen again.” Neil obliged by setting it a few degrees higher and went back to his normal business.Later that afternoon, Neil was working on documentation when the office again went black. “OH COME ON!” a frustrated programmer shouted from across the office. “NEIL! I SAID THIS CAN’T HAPPEN AGAIN!” Jack roared out like a lion in the darkness.“I’m on it, Jack!” Neil replied, frustrated. Luckily he still had the flashlight on his desk and the power was back on in a jiffy. He knew telling Jack he didn’t have an explanation wouldn’t fly this time, so he would not rest until he found the culprit. Of course, there was no obvious cause. Neil searched the building top to bottom, and couldn’t figure out the cause. He swore to figure it out the following day.The next day was the hottest of the day of the year, and Neil dreaded the load the HVAC system was putting on the electrical system- and sure enough, the power went out again. Jack shouted his anger, and Neil scurried off to the basement to fix the problem. With the lights on, as he came back up to the top of the stairs, Neil spotted Mike trying to sneak out the side door with a large object.“What you got there, Mike?” Neil asked with suspicion.“Oh, um, nothing,” Mike stammered, as he turned towards Neil with a large space heater in his hands. “It’s just that it gets so damn cold by my desk, I decided to bring this heater in and, it’s probably just a coincidence, but when I do this…” Mike bent down to plug the heater in a nearby outlet.“Mike, NO!!!” Neil couldn’t stop him fast enough as the heater fired up for a split second before the eerie quiet of a power outage returned. “You fool! You can go explain to Jack why the power keeps going out while I go back to the stupid basement.”[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll 👍 today.Your first 30 days are free on us. Learn more at Scout.
CodeSOD: Taking Exception
Like many enterprise organizations, Martin’s workplace decided that they needed to build a collection of .NET assemblies which would be used in every application they built, and would provide important facilities like error handling.And of course, not only would every application need to use these libraries, every application needed to make use of every component in them, otherwise why have the libraries at all? This meant that every Exception thrown by the application needed to inherit from the BaseException class:
Sharked
Andrew M. worked at a small company in Kansas City called EtherTrode. With one facility and about 20 employees, they designed and built custom Ethernet hardware and drivers to fill niche roles where the common integrated chipsets weren’t good enough. Their hardware worked quite well, which attracted the attention of a multinational conglomerate called Initech. Initech puchased EtherTrode, rather than develop their own Ethernet devices.Like most others at EtherTrode, Andrew was a jack-of-all-trades. On any given day, he might be doing anything from customer support, to application development, to general office IT tasks, and even once a bit of soldering. It was the general office IT tasks that got Initech’s attention: he was selected to work with Initech on integrating their networks.The first phase went more-or-less smoothly. Initech shipped Andrew a pre-configured Cisco router, and instructions on how to connect it. After a weekend of integration, EtherTrode’s network now had a permanent VPN tunnel to Initech’s headquarters in Detroit.Phase One was boring. Yes, there were minor screwups and a few WTFs due to some miscommunication and unnecessary outsourcing, but that’s a variation on the same story that’s been told a million times before. Phase Two, however, was the Grand Slam over the foul line, lightning in the whiskey warehouse, the Cheese Shop without cheese, and a painful urination upon a subway’s third rail…… Active Directory Integration.Once the networks were connected, Initech wanted to terminate EtherTrode’s Active Directory domain and move all of their accounts and systems into Initech’s domain. Contractors working for Initech prepared a new domain server and shipped it to Andrew. He received the system, racked it the next weekend, and powered it on. Everything seemed to work, and local systems joined to Initech’s domain without issues. Come Monday morning, the office was ready to resume business.Things turned sour around lunchtime on Monday. All morning, employees had complained about poor network performance. Their emails failed to send, and new messages failed to arrive. Tiny Subversion check-ins would fail more often than not, and even internal web pages took minutes to load- if they loaded at all. Worse still, Initech’s security officers had installed a new electronic lock system on EtherTrode’s building, which was connected to the LAN. By lunchtime, the locks refused to unlock, and Andrew had to physically unplug the controller unit in the server room to disable the lock so employees could actually enter and exit.The core staff of EtherTrode had an impromptu meeting shortly after lunch to discuss the issues. Lyle, another engineer, arrived late. “But I know what the problem is,” he explained.“I noticed the lights on our core switch were blinking like a strobe light in a tornado, so I fired up Wireshark.” A few of the engineers nodded, and Andrew wondered why he hadn’t thought of that. EtherTrode made Ethernet equipment, and Wireshark was an invaluable tool for examining the behavior of their devices and networks. It was the best way to make sure their hardware complied with Ethernet and TCP/IP standards, and it was really good at not interfering with their network while doing its monitoring. “In short,” Lyle explained, “there’s a device at 192.168.16.245 that’s issuing tens of thousands of broadcasts per second. The switches are dropping frames, and the IP stack on everyone’s workstation is working overtime processing irrelevant packets.”“254, you say?” Andrew said. He frowned. “That’s the IP address of our new domain server…”“Can we shut it down?” asked Ryan, their boss. “Rollback to how our network was last week?”Andrew shook his head. “I’ve already joined everything to the new domain. If we shut down the controller, no one will be able to log in or access network resources… not that they can now.”Lyle spoke up again. “The traffic looks pretty fishy. I think the server’s got some sort of malware on it. Can we log in and see what it’s doing? Run an antivirus or kill the process?”Andrew shook his head again. “Initech has it locked down tight. I can do some basic domain admin tasks, but I can’t actually log into the server.”“Alright,” Ryan said, visibly irritated, “Lyle, give me your Wireshark capture. I’m going to go down to the coffee shop for their wi-fi, and I’m going to forward it to Initech and raise some hell.”In the meantime, Andrew and Lyle went back to the switch. Since the broadcast was on a single port, they blocked that port at the switch. The server kept shouting its head off, but now the switch dropped the packets. Doing anything that required talking to the domain server- like logging in- was painfully slow and failed half the time, but the rest of the network worked fine. That bought them some time while they waited for a better solution from Initech.The next day, Andrew came in, grabbed a mug of coffee, and picked up the top priority support ticket. This one was a customer support issue. They had uploaded their own Wireshark capture to an FTP server. Andrew downloaded it so that he could see why their EtherTrode equipment was misbehaving. When he went to open the capture, Wireshark refused to start- or more accurately, it was no longer installed on his system.“That’s strange,” Andrew thought to himself. Maybe a Windows Update messed up the registry settings, or something, so Andrew redownloaded Wireshark and ran the installer.Or tried to. The installer refused to run. “This publisher has been blocked by your administrator,” explained the error message. As if on cue, his email client dinged and he was a new memo from the Initech IT department:
CodeSOD: Filter Overflow
Onboarding was complete, and Denise finally had her PC. Time for her first assignment!"It's really pretty straightforward," her new boss had said, with a resigned look in his eye that betrayed it wasn't actually straightforward. "Your predecessor almost had this new CMS complete, we just need filtering on the frontend search."It wasn't glamorous, but it was probably a good way to get her feet wet in a new organization. The requirement was to fetch a list of image IDs that corresponded with a business ID so that users only saw the images for their group. Simple, straightforward, obvious. She had it done inside of a few days and sent to the users for UAT.And that's when the change requests started."Can you make it filter by state? Like, hidden images, public images, that sort of thing?" Sure, easy enough."What about filtering by upload date? Like if I gave you a date range?" Um, sure, but it'll add to the time...Even after the filter was in production, the list of requests kept rolling in, bypassing the helpdesk and going right to her email inbox. "We're getting a lot of spam images, can we filter so only verified users' uploads show up?"Denise's boss told her it'd be over faster if she just gave in and made the change. Management would ultimately decide to do it after wasting her time with meeting after meeting to discuss priority anyway."Can we put videos in the CMS?""Can we filter by tags?""I need to filter images that are actually images.""Can we sort on the tags?” How do you sort on tags? Denise wondered. Apparently, by their business IDs. Sure. Whatever."I'm still getting images that shouldn't be showing up. Can we filter for only images that show up?""There's too many images, can I limit it to ten per ID?"Finally, she ended up with this giant Ruby monstrosity:
Error'd: See Something? Say Something!
Patrick wrote, "I was at Penn Station in NYC, and, well, I just had to say something!"
The Depths of Insanity
George G. came to the Pierce & Pierce office in good spirits and with high hopes. After finally gathering the courage to run away from his previous job, which had involved maintaining a million-line, 15-year-old mess of a codebase, he'd spent the last month interviewing with nearly every tech company in his area. Here he'd found his Promised Land: a modern-looking, professional company with a suite of cutting-edge technologies and, most importantly, a new and interesting project to which George would be assigned.Or at least that was what Pierce & Pierce had promised at the interview."Well, you see, there's been a reorg." George had barely sat down at his desk for the first time when his manager brought him the news. "All new projects are on ice. We're gonna be putting you on our flagship product instead. Don't worry, we'll have something real cutting-edge for you soon!"Flagship product? That could only mean one thing: legacy code. Another aging codebase which, thanks to the company's "innovative performance-boosting management methods," clocked in at five million lines of uncommented, undocumented code. As much as George wanted to get up and leave at such news, he decided to bite the bullet and give Pierce & Pierce a chance ... for now.He received his first assignment almost immediately. The application failed to read a particular line from a config file, and the task was to investigate and fix the issue.Well, that should be simple, he thought. I just need to find the place where the config file gets opened, then there should be some loop that reads it and looks for that line. Easy-peasy.He submitted a one-hour time estimate, giving himself some leeway, then got down to hunting the bug.Unfortunately, things weren't so simple. What was supposed to be a quick, introductory trip through the codebase turned out to be a strenuous excavation through layer upon layer of abstract factory builders, inline lambdas spinning off separate threads, callbacks to callbacks, and other examples of architecture astronautics—all to simply read the configuration file.Four days later, George managed to find something resembling an error logger. He set a breakpoint and ran the application, hoping to work his way through the call stack to where the issue lay.Sure enough, the breakpoint was hit almost immediately. But even before George started reading the stack trace, he knew it wouldn’t be of much use. The list of classes looked something like this:
Bring Your Own Code: The End of the Lucky Deuce
What feels like forever ago, we introduced the Lucky Deuce casino contest. This is a series of challenges, brought to you by our pals over at Infragistics, where we call on you to help us build a “scoundrel’s casino”.Last week, we introduced our final challenge: take one of our casino games, add a betting system, and then build a strategy that lets you keep playing (by distributing the load across multiple accounts).Once again, we had a nice pile of great submissions, and there are two who are going to get to take home a nice TDWTF hoodie for their troubles. As always, check out the full projects on GitHub.For all of our winners (from this week or any previous)- or anyone who entered using Infragistics controls- expect an email in the next week or two to follow up about how best to get you prizes.WinnersFirst, let’s talk about Bruno’s solution. For bonus points, he decided that his system should be able to detect a user’s gender by their name:
'Tis the Season
Deep in the wooded vales of red state America, December is hallowed not just for hunting presents, but also hunting deer. Lo, the season opened on a Friday. Clayton’s consulting firm declared it Camo Day in celebration.Employees festooned themselves and their office in their brown-and-green finest. Some posted deer horns and small taxidermic animals in prominent locations. While this particular company stopped short of installing a shotgun in the kitchen, just in case a bear happened along, it was still the most redneck of wonderlands.Clayton could even swear he smelled hunting musk as he moved through the floor, trying to get back to his desk after an exhausting code review. And everywhere he looked, camouflage-print duct tape lingered like traces of scat: patching a hole in the carpet, propping up the back of a swivel chair, cradling a leaky ceiling tile …Both tape and musk led to his manager Buck’s office.“How you doin’, Clayton!” His voice boomed out from the office like a blunderbuss’ payload, halting Clayton in his tracks. “How’d that code review go?”Clayton peeked in to find Buck applying a piece of camo duct tape to a patch of ruined drywall behind his desk chair. He ignored the scene to reply, “Fine. John has some changes to make, but nothing major.”“Good, good.” Buck rubbed a fist over the newly applied tape. “Don’t mind me, I’m just taking the initiative to fix a few things around here.”Clayton debated whether to say anything. In the end, he couldn’t help himself. “Uh, all that stuff you’re fixing probably needs more than duct tape.”This prompted Buck’s ringing laugh. “If you can’t fix it with duct tape, you’re not using enough!” Finished with the wall, Buck turned, yanked his laptop out of its docking station, and began wrapping the camo-colored tape around it.Clayton really knew better, but again couldn’t help himself. “What are you doing?”“Decorating my laptop!” Buck replied.“But … you’re covering the vents,” Clayton managed around his shock. “It’s gonna overheat.”“It’s winter and it’s cold out! This thing’ll be fine.”“Win—you’re taking it outside?” Clayton faltered.“Out to my hunting blind! I’m cutting out early to get a jump on the season.” Buck reached into his pocket. Out came an obnoxiously sized lock-back knife that he used to slice a gap into the tape layer, allowing him to open up the laptop.“Why bother working remotely?” Clayton asked. “Just call it a week.”“The usual BS quarterly meeting is this afternoon—of course.” Buck rolled his eyes. “Gotta join the WebEx and at least pretend to pay attention.”The WebEx would handle both video and audio for the meeting. Clayton imagined the deer would take a dim view to budget projections, but Buck’s laptop did have a mute button.“Happy hunting, champ! I’ll have my cell phone in case you need anything.” Buck packed his laptop, then gathered his coat and a cooler that was almost certainly full of beer.“Uh, OK.”In the end, Clayton couldn’t complain about a manager-free afternoon. He returned to his desk, dug into his work, and all was well.A few hours later, his desk phone rang. Buck’s cell.Clayton internalized a curse and picked up the phone. “Hello?”There was nothing on the other end at first aside from scuffling, and a string of very not-internalized curses from Buck.“Boss?” Clayton prompted.“The damn thing’s a brick!” Buck cried.“What is?” Clayton asked.“It just shut down on me!”“Your laptop?”“And the damn meeting’s still on!” More scuffling noises from Buck’s end. “Hopefully everyone’s too busy snoozing to notice I fell off the WebEx. Hang on, I’ll be in the office soon!”Clayton didn’t bother stifling his groan, but managed to hang up before it escaped.Twenty minutes later, Buck stampeded into his cube, cooler and laptop in tow. He dropped the camouflaged computer onto Clayton’s desk, shaking out his hand. “Sumbitch shut down on me out of nowhere!”Clayton felt the waves of hot fury radiating off the laptop when he stuck his hand near it. “It overheated, like I said. You blocked the fans that keep air circulating through there,” he explained. “We gotta get this tape off.”“Nah! If it’s hot, we just gotta cool it down, right?” Buck opened up his cooler and pulled out a half-melted bag of ice. He then turned and dropped said bag directly onto the laptop.Clayton’s jaw fell. Should he bother to say anything? No, it never helped.“While it’s cooling off, I’ll need your computer to log back into the WebEx,” Buck said.Clayton suppressed his instinctive panic. “You have to leave it here. No ice or camo. I’m done for the day, and I’m not touching any more work until Monday! Deal?”“Deal.”With a collecting breath, Clayton logged out, then stood to gather his belongings. “There you go.”Buck clapped him on the shoulder. “Happy hunting, champ!”[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll 👍 today.Your first 30 days are free on us. Learn more at Scout.
Classic WTF: The Non-Deleting Delete
It's a holiday in the US today, which means we're taking a 3-day weekend to dig back through the archives and find a classic WTF. One of my favorite features- one that we run far too rarely- are the true confessions. Sometimes, we are TRWTF, and let's applaud Matthew Schaad's story about his misuse of database triggers. - RemyIt started out as an average day for a developer like me. At 11:30AM, I was just getting into the office and fixing my second cup of coffee for the day. Being in the habit of coding till 3:00AM nightly, I was averaging about three to four cups a day. As I sat down at my desk to tackle one the several projects I had been assigned, I got a frantic call from the Director of IT, Jeremy.“Matt!” the telephone receiver shouted.“Yes?” I responded coolly, as I was used to hearing about fires that needed to be put out yesterday.“The reservation system is not allowing users to delete their reservations! Martin booked a conference room every Thursday for several years out, and now he can't delete it. Can you take a look at it?”“Sure, no problem,” I replied before hanging up the phone and going back to sipping my coffee.Jeremy was referring to our company reservation system. Similar to Outlook, we use it to manage shared resources, such as conference rooms, company cars and IT equipment. It isn't the most reliable system, and we constantly get complaints about it. Most of the time, though, the problems seem to arise between the chair and keyboard.So having gotten my marching orders, I opened up the database, wrote a quick DELETE statement, ran it, and saw that it deleted all the records for Martin’s recurring appointment:
Error'd: Crotia? Slovania? DO NOT USE!
"Canada? Yes! At least they got that one right!" Steve M. writes.
The Wunderkind
Software needs to run quickly. Whether it's to get a response to a shopper so they don't get bored and click on to the next site, or performing calculations on some data that is urgently needed downstream. Efficiency is important!To that end, most developers attempt to write code that runs quickly. Sometimes, the code needs to run more quickly than conventional means will allow. In those cases, smart developers will figure out how to game the system to get the computer/network/disks/etc. to get things done more quickly than the usual methodologies permit. For example, you might try to cut network overhead by stuffing multiple small requests into one buffer to take advantage of the leftover space created by network packet sizes.Of course, if you're going to do something sophisticated, it's common courtesy to document what you're doing, and why, so the next person who has to maintain your code will know how to proceed.Unfortunately, not all developers are smart, or considerate.Ralph worked on a mature Java/C++ project that needed to replace an even more decrepit mature reporting system. After several half-hearted starts, his company bought a competitor that had a pretty decent reporting system that was written and supported by The Wunderkind.The Wunderkind convinced management that the reasons that he was so successful were that:
Bring Your Own Code: Getting Comped
Today brings us the fifth and final entry about the Lucky Deuce. This is a series of challenges, brought to you by our pals over at Infragistics, where we call on you to help us build a “scoundrel’s casino”. Read to the end, because this week's challenge has a bigger prize- some TDWTF-emblazoned hoodies for the best entries.Last week was your first shot at a “straight” solution, and the entries really showed it. Pretty much everybody got straight into the problem.Honorable MentionsRobert for example, implemented his solution as a straight-forward WinForms application in C#. What gets him his credit is… interesting extension to a simple die class he wrote which helps him count die combinations later:
CodeSOD: Byte me
The great thing about Android is the low barrier to entry: thanks to open-source tooling, emulators, and the decision to build on a language often taught in schools, just about anyone can write a simple little app.The worst thing about Android is the low barrier to entry. Just about anyone can write a simple little app, whether they know what they're doing or not. The following code snippet is intended to take bytes from an InputStream (a common paradigm for web in Java) and save them into a file.
Enlisted
After a 6-year enlistment with the United States Air Force, followed by a 4-year degree in Computer Science (paid for by “Uncle Sam”), Tony S. joined with a small company that specialized in criminal background checks. “No more unpaid overtime!” he’d thought to himself upon joining the civilian world for the first time since high school. “No more screaming officers! No more sleepless nights from trying to meet deadlines!”Tony quickly noticed his new employer had efficiency problems. They tracked everything the company did in an Excel/VBA monstrosity that had been cobbled together. Wanting to show initiative, Tony suggested that he could build a database-driven website to replace it. His boss agreed, and they drew out a three-phase plan to implement and deploy his idea.Phase 1After a month of design and development, Phase 1 was well underway. Tony had written the basic data-layer for the application. It didn’t have many features, but could easily show some of the company’s in-progress projects he’d manually imported from the toxic hellstew of spreadsheets. Pleased with his progress, he scheduled a meeting with his boss and the data leads to demo it.During the demo, his boss cut him off. “Who authorized this project?” she interrupted.Tony paused. Did she not remember helping him plan it all? “I… um… uh… you did.”“I did no such thing. How long have you been working on this?”“About four weeks now,” he replied, acutely aware of the burning sensation on his cheeks as his boss grilled him in front of everyone. “You helped me pl…”“We can’t have our employees spending this much time on unapproved projects!” she yelled.The meeting got worse from there. In the end, his boss relented, but declared that Phase 2 and Phase 3 would never happen. In addition, she gave him a list of features that had to be delivered by the Phase 1 deadline- a list that conveniently included everything from Phases 2 and 3.Phase 1, Part 2Tony tried to continue on the project, but now that his boss was involved, requirements constantly changed. One day, he was asked to add in a full-fledged help-desk ticket tracker, and the next day he was asked to rip out the third-party helpdesk library he’d integrated because it was a “security risk”. His boss demanded that it be implemented from scratch, and refused to budge on the deadline.“That’s not enough time!” Tony complained.“It will be,” she said, fixing him with a stare so cold it could freeze Hell. “Or you won’t be working here anymore.” With a wave of her hand, she dismissed him.Tony soon found himself working 15–16 hours a day, 6–8 days a week, trying to meet the deadline and keep his job. He worked hard, but the hours took their toll. Life left his eyes and he slowly decayed into a zombie which smelled strongly of coffee.Phase 1, Part 3…ish?Two days before the deadline, Tony completed the last of the requirements. The application was buggier than a roach motel, but most of the issues could be worked around and fixed later. He headed home, though he didn’t remember it, and passed out. He’d only had about 3 hours of sleep in the past few days. Simple concepts, like sleep, time, and food, and sleep, and lists were now only vague memories he couldn’t quite grasp anymore.He woke to the buzzing of his cellphone. The clock read 1PM, and the caller ID was for his boss.“Why aren’t you at work today? Tony, this is unacceptable! I can’t have lazy employees skipping out on work! I am going to have to discipline you, and this is going in your file. Get to the office RIGHT NOW!!!”Enough was enough. Tony didn’t rush straight to the office. He spent the next ten minutes typing up his resignation letter. Then he went to work. As soon as he entered his boss’s office, she launched into a new round of screaming anger. “You are the worst employee I’ve ever had! You invent make-work projects, you come in late. Look how late it is! Don’t think I didn’t notice you leaving early and taking long lunches! There’s only one response for this inexcusable pattern of unprofessional behavior- I have to fire you! Stay here for the rest of the day and get your stuff sorted out, and I’ll arrange for HR to…”Tony mentally phased out at that point. He dropped his resignation letter on her desk, turned around, and walked out. He paid no attention to the shouts that grew louder as his boss became more inflamed from this apparent insubordination. As he left the building, he considered re-enlisting. Maybe scrubbing toilets with a toothbrush at oh-dark-thirty while getting screamed at by a drunk Second Lieutenant with an ego problem, after a double-shift of guard duty, wasn’t so bad after all.[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!
Error'd: Political Errors
"I agree, Google. When it comes to news coverage of politically sensitive topics, many errors have occurred," writes Scott.
No Changes Please
A new codebase at a new job is a lot like a new relationship: everything’s great until you really get to know each other. Just ask Bradley, who joined Javatechsoft Industries a few months ago. He was brought on to lend a hand with an overdue project. The pay was good, the job came with life insurance, and he had plenty of experience with Enterprise Java. It seemed like the perfect fit.Specs came in, Bradley shipped code out, and their honeymoon was smooth sailing. The bad things crept up slowly, poking their heads out of the code in funny little ways that didn’t seem like a big deal, they were kind of cute, until…
Bring Your Own Code: A Fever on a Crappy Day
It feels like forever ago, we introduced the Lucky Deuce casino contest. This is a series of challenges, brought to you by our pals over at Infragistics, where we call on you to help us build a “scoundrel’s casino”. We are nearing the end of this little BYOC contest- this week is our last "all original" round, and next week, we'll introduce one final challenge that leverages code you may have already written for this contest.Last week, you had a tricky little problem: you needed to write some code that looked like it was going to cheat, but really would get the cheater caught.Before we get to the Honorable Mentions, let’s once again tip our hat to Alexander, who once again decided to enter using APL. What can I say, I’m a sucker for any language that requires a specialized keyboard to write.cards←{⊃a ⎕RL←(⊂↓5 5⍴,{⍵[25?⍴⍵]}d↓↑,5/{(,'CDSH'[⍺]),(('234567890JQKA')[⍵])}/¨⍳4 13),⊃ts,d←200⌊0⌈¯1200+⎕RL-⍨ts←200⊥2↑3↓⎕TS}As always, all of the winners are up on GitHub.Honorable MentionsThis one’s from Niels, who did a good job hiding his cheat deep down in a .NET feature called an extension method (for the unfamiliar, extension methods let you “add” methods to classes without actually changing the classes’ implementations).
CodeSOD: Foxy Checksum
Pavel D inherited some… we’ll call it “software”… that helps run warehouse operations for a boiler/heating manufacturer. That software was a Visual FoxPro database.Now, this application needs to read barcodes off of products in the warehouse. Since the laser-scanners can sometimes mis-read those barcodes, the database uses a custom check-sum algorithm.
The Old Ways
Greg never thought he’d meet a real-life mentat.“We’re so happy to have you aboard,” said Jordan, the CEO of IniTech. She showed Greg to the back end of the office, to a closed door marked with just one word: Frank. Jordan, not bothering to knock, opening the door.Greg was overwhelmed with the stench of burned coffee and old-man smell. The office was unadorned and dark, the blinds drawn, illuminated by the blue light coming from an aging CRT screen. He saw a wrinkled scalp behind a tall, black office chair.“I’m busy,” Frank said.Jordan cleared her throat. “This is your new programming partner.”“I’m Greg. It’s nice to meet you–” Greg offered his hand, but a wrinkled appendage slapped it away.“Get yourself a chair. I know where everything is. You just show me you can type.”Greg shot Jordan a glance as they left Frank’s office.“He’s been with us 22 years,” she said. “He knows everything about our code. But his typing’s not what it used to be. Just do what he says. With some luck he’ll be retiring in a few months.”Total RecallGreg pulled a spare office chair into Frank’s den. He could see Frank’s face in profile now, resembling the mummy of Rameses II. Frank slid his keyboard to Greg. “Open C:\project.make in Vim,” Frank said, “and go to line 22.”Greg thought it was odd that a makefile would right under C:\, but he did so. He moved the cursor to line 22.“Increment $VERSION to 8.3.3.”Greg noticed that Frank had his eyes shut, but humored him. In fact, line 22 did declare a $VERSION constant, and Greg changed it to 8.3.3.“You’ll be suitable,” Frank said, crossing his arms. “You’ll do your work from the SMB server. Don’t make any changes without my authorization first.”Change ManagementBack at his desk, Greg found the SMB server where Frank kept all of his code. Or rather, the SMB mapped all of the files on Frank’s hard drive. Curious, Greg searched for .pas, .make, and other source files, wondering why Frank would keep his principle makefile under C:\.There were 440 source files, about 200 megabytes, spread out all over the directory strucure. C:\Windows\System32, C:\Users\Shared\Project, C:\Program Files\… Frank’s entire computer was the de facto source repository.Greg knew if he ever had to make an on-the-fly change to the source, it would take hours just tracking down the right file on SMB. Surely they had a repository he could check changes into. Greg took a deep breath and re-entered Frank’s den.“Frank, do we have any of this in a repo somewhere? I don’t want to SMB onto your computer every time we make a change. What if we have to patch something overnight?”“What?!” Frank rose from his office chair, unsteady on his disused legs. “There will be no code changes without my direct supervision! It’s worked just fine for 22 years. Is that understood?”In MemoryGreg endured this for several months. Frank would harbor no suggestions of version control or repos. Everything, Frank said, was in his head. As long as no one changed the source without his permission, he would know where everything was.Despite his frustrations, it greatly impressed Greg. Especially when Frank had memorized loop variables such as these:
Error'd: Nil, null, nihilism
"Figures. A suggestion devoid of meaning," writes Blake R..
Thorough Monitoring
Mr. Reynholm took great pride in his technical knowledge. Of course, as is often the case with CEOs and self-appointed CTOs of technology startups, that didn't necessarily mean he possessed any in the first place. But what Mr. Reynholm lacked in skills, he made up for in charisma. His designer suit, Brilliantine-laden hair, and the ability to turn a reading of El Reg with a thesaurus into a business pitch kept the company afloat despite the lack of any real product to speak of.And as Jenny sat behind her ebony desk in Reynholm CorpoTech's office, reminiscing about her "technical" interview from two weeks ago, she thought that maybe she shouldn't have been that eager to accept her first real job offer from Mr. Reynholm's hands.Suddenly, the loud ding of an Outlook notification snapped her out of her thoughts."Hey, Rob," she asked a young guy sitting to her right, "what's a, um ... Technical Meet-Up With Mr. Reynholm? Do I need to attend?""What, again?" Rob sighed, checking his email. "Aw, no. Aww, Jesus. And it's this afternoon?""Let me guess, it's not a fun ride?" Jenny asked."Well, that depends on how much you value your sanity," Rob said. "Think 30 minutes of buzzword bingo plus 30 minutes of Star Trek-grade technobabble, blended together to give you an hour of absolute common sense violation.""Yikes. Can I—?""No, you have to be there," Rob interrupted her. "But hey, there's always pizza afterwards. It's from some really good place, too: Mario's Pizza, or something like that."Jenny decided to bite the bullet. After all, meetings were part of a professional programmer's job. Numbing her brain for an hour couldn't be that hard.The shiny, high-tech meeting room easily hosted all the company's coders. While most of them eyed the side door, hoping for the pizza guy to show up, Jenny focused on a large, strange object in front of the speaker's podium, covered with a bedsheet."What do you think that is?" she poked one of her colleagues.“No idea," he said, trying to hide a yawn. "Probably some marketing gadget. Trust me, there's no way it's something interes—""AHEM! Let's start, shall we?"The lights in the room cut off as Mr. Reynholm entered the stage, silencing everyone."So! Developers! Developers, developers, developers, as one Steve Ballmer used to say. The best of the best, crème de la crème, the relentless force of progress! Do you know why I gathered you here?"Nobody raised a hand. Well, Jenny thought, it's not like you bothered to include an agenda..."You see, here at Reynholm CorpoTech, our mission is to bring technology to everyone. It doesn't matter who or where you are. If you want to take this journey with us, we're waiting for you with arms wide open. For you see, I had a dream, and in that dream I was a poor child living on the streets..."As much as Jenny tried to stay professional, her attention frequently wandered away from the speech."...and by making our company webpage viewable from even low-budget devices, we'll make our userbase as inclusive as possible. Which brings me to today's topic: responsive web design! You see, content is like water..."The audience's collective grimace told Jenny it was okay to let go. A lot of words were being said, but none were worth listening to.A half-hour later, the lights cut back on, startling everyone awake just as Mr. Reynholm approached the sheet-covered contraption."And now, I present to you ... The Responsive Testing Workbench!" He pulled away the sheet and let it drift to the floor.Jenny blinked, then blinked again. The revealed table housed a great-looking PC tower, an ergonomic keyboard and mouse ... and six monitors of different sizes, from a huge 4K to a tiny fourteen-inch CRT hooked to a converter."With this setup, we'll be able to see how our website fits on any screen," Mr. Reynholm explained triumphantly. "Tiny ones, huge ones, we're prepared for anything! And I see we already have questions! Jenny, wasn't it?"Jenny nodded, her raised hand still in the air. "Um, do we need all those screens? Can't we just test the website at different resolutions?"Everyone was looking at her now—some with a smirk, others with genuine compassion in their eyes.Mr. Reynholm didn't miss a beat. "Of course we could, and we will, but that's not the point! You see, when you browse the website on this huge screen, the fonts and images are bigger. On a small screen, they're smaller. So we need these monitors to see the website through our all our users' eyes. Understood?""But ... but ..." Jenny was about to object, but the first lesson in being a successful employee dawned on her. Sometimes it's better to let your opponent win. "I guess you're right. Sorry.""Now now, no need to apologize, we're all here to learn! Now, back to the Workbench ..."Months passed slowly at Reynholm CorpoTech. With two top-tier graphic cards, an overclocked processor, and open administrator account, the Workbench found its true purpose as a great time-wasting device. As for Jenny, she gained confidence and bonded with her team, but as the torrent of venture capital slowed to a trickle with no projects past the planning stage, she found herself looking for greener pastures.Eventually, she ended up in front of Mr. Reynholm's office door."Oh, Jenny! Come on in,” he waved her inside. "By the way, have you seen any 14-inch monitors around here? I want to check the website at that size, but the Workbench is busy.""No, I don't think we have any," Jenny said. "Can I show you a little trick, though?""Oh, I love learning new things! Come on, I'm all ears!" He shoved away from his PC, offering her control of the keyboard and mouse.Jenny found the resolution settings and scaled them down to 1024x768.Mr. Reynholm marveled at the results. "Now that's clever! That means I can finally test the website from my own office! It's nice to have all you geeks around to teach an old man new tricks.""I hope you can make do with one less," Jenny said, handing Mr. Reynholm the envelope with her two-week notice. "I'm sorry. It was great working here, but I guess … I guess sometimes you need to look at things from several perspectives."[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll 👍 today.Your first 30 days are free on us. Learn more at Scout.
Bring Your Own Code: The Lucky Deuce: In the Cards
Two weeks back, we introduced the Lucky Deuce casino contest. This is a series of challenges, brought to you by our pals over at Infragistics, where we call on you to help us build a “scoundrel’s casino”.Last Week, you were again given some vague requirements, this time for building a broken slot machine. Once again, we had some seriously great submissions. Like last week, I’ve rehosted the winning code here.Honorable MentionsWe didn’t get quite as many submissions this time around, but while folks didn’t quite top themselves for quantity, we still got some serious quality.First, we have to give credit to Alexander, who delivered his submission in APL. That’s a clever solution for making certain your code is obfuscated enough that nobody will detect your cheat.
CodeSOD: At Least There's Tests
Having automated tests for a project is a good thing, as a general rule. We can debate the broader merits of “TDD”, “ATDD”, “BDD”, “ATBDDSM”, how much test coverage is actually worth having, and if we should view our test approach as a series of metrics that must be met, instead of some guidelines that will help improve our development process.Our first exhibit today is from Paul. It’s a JUnit test, that, well, maybe misses the point of writing unit tests:
Reactions
Data Security. We all need to deal with it. There are many tried and true ways of doing things. Many of the problems you'll encounter have been solved. Some of them will require creative thinking. All require a basic understanding of the difference between big thing and little thing. Not everyone possesses the ability to differentiate between the two.R.J. works for a health insurance company. These folks have access to some of our most private information, and take HIPAA regulations to secure and protect it quite seriously. Any breach of security requires notifying customers of potential exposure, as well as reporting to government imps bureaucrats better not dealt with. Naturally, the bean counters from the board on down all repeat the mantra of protecting the customer data at all costs.The team that employs R.J. developed the phone menu system. You're familiar with these beasts; they're designed to teach you Zen levels of patience while you try to do something, anything, while preventing you from having contact with a human. To that end, they allow you to perform all manner of tasks, provided you can stumble through the maze to the right sub-menu, and enter the magic code(s).One day, while snoozing on his bus ride home, R.J. got an emergency email entitled Potential Personal Health Information Exposure. As he grudgingly opened the email, the familiar Star Trek red-alert security-whoop sounded. The mail details stated that every enterprise level team (e.g.: all of them) had to be on an emergency call immediately! Wanting to be a good Red Shirt, R.J. jumped onto the call.Unfortunately, along with 9 levels of management, all in full panic mode, there was only one other person on the call; a DBA.After 15 minutes of managers pouring gas on the fire and assuring each other that there was plenty to panic about, the DBA got a moment to talk. There wasn't an actual data breach and no information had been affected or viewed. As part of a routine audit, the DBAs had discovered that a determined individual could find out that member id nnnnnnnnn had a birthday of yyyy-mm-dd. The DBAs already had a fix and just wanted to let the consumers of the data (e.g.: R.J., and all the other teams that hadn't joined the call) know that the affected data would be unavailable for a few hours while they applied their change.This set the managers off on a rant that could only be had if you were a manager:
Error'd: Are You Using?
"No! Never! Absolutely not!...Well, OK, back in college. Just once," writes Jack R..
Jibber Jabbered
Robert was proud of the system diagnostic and monitoring setup he architected, despite his manager Jim's weird insistence that it be done with XMPP. Their company was responsible for managing network infrastructure at a variety of customer sites, so each customer ran a network monitor that used an off-the-shelf Jabber client to phone home. That central XMPP server itself was Ejabberd and would communicate with all remote nodes via SSL, happily returning information that no one but Robert and his team could read. In order to prevent other nodes from talking to each other, they were only buddied with the central XMPP server. It was the "perfect" setup.As tends to happen with people who do good work, Robert got pulled away from his XMPP system to save another project from sinking. It would continue to work well enough on its own without much hand-holding. When new nodes needed to be added to the system, that duty fell to Robert's coworker Jens. He kept complaining that it was too much work to pair the new nodes with the XMPP server, but Robert brushed it off because for someone like Jens, tying his shoes was too much work.Jens had been mysteriously quiet about the XMPP setup duties for a while, before he randomly shouted "I just showed you up, Bobby!" one day. Robert assumed he accomplished something meaningless like topping the office high score in Tetris. "Since your XMPP system is so hard to maintain, I took the opportunity to make some improvements! No more painful setup!"Robert immediately began to feel a sense of dread. Anything Jens touched turned to crap and now he had been messing with Robert's pet project. "What exactly did you do, Jens? Everything was set up the way it needed to be for security's sake.""First, I got rid of that EJabberwocky setup, or whatever it was. That was pointless- there are much more lightweight Jabber servers out there!. Then I created a single account group for all the nodes so now whenever we add a new one, BAM! It can automatically talk to the XMPP server. This is way more manageable than the junk you had set up."Every client site was now buddied with *every other* client site. "Dammit, Jens! Why couldn't you just leave it alone?" Robert said, fuming. "Do you realize that now every node can talk to every other node and get information from it?""Yeah, well so what?" Jens retorted, taking up a defensive posture. "What are they going to do, have a big chat party? Chill out, man.""No, this means that anyone out there who has access to our remote nodes can simply log in and get information from every other node on the network, including the ones at customer sites.""HA! What are the odds of that happening?" Jens scoffed. "Let's take it to Jim and see what he thinks!"Robert and Jens raced to Jim's office to see who could prove their point first. Robert won but didn't get the answer he was hoping for. "You see, Robert," Jim began to explain, "we can do things the hard way here, or we can do them the efficient way. What Jens has done here will save him countless hours of setup over the course of a year, freeing him up to do even more important things!"Robert swallowed his pride as they left Jim's office, Jens sneering behind him. Jens destroyed his perfect system, and gave himself more time to screw other things up in the process. Robert was left to wonder if he should give Jens an unexpected Ejabberd to the throat as payback.[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!
Bring Your Own Code: The Lucky Deuce: Getting in the Slot
Last week, we introduced the Lucky Deuce casino contest. This is a series of challenges, brought to you by our pals over at Infragistics, where we call on you to help us build a “scoundrel’s casino”.Last week’s challenge was to build a “broken” roulette wheel, that instead of being truly random, avoids recently spun numbers to “feel” more random. I’ve rehosted all of the winners’ code here.Honorable MentionsMany of you noticed that, with our rather silly requirements, you didn’t need to do anything to make a cheating wheel. By simply betting on the least recently used numbers, your odds were enough to beat the house. This was true, but that’s not a terribly fun approach. Still, Ryan gets credit for taking that reality and putting a “thumb” on the wheel, so to speak. His solution was to be a little sloppy in how he weighted the probabilities, taking a heavy hand:
CodeSOD: Count On It
If there's one thing more exhausting and ridiculously over-complicated than moving house, it's moving legacy apps. Something as simple as a migration to another, identically configured (in theory) server can cause unexplained breakages and weird glitches in bits of the code no current staff member has ever touched.Mikail's company knew better than to try to extract this particular app and repot it in another server. After all, most of the core functionality was written by interns several years back, and since it wasn't in source control at the time, nobody had been willing to touch it. But with a major merger came a domain name change, leading to a slew of unexpected errors in production (Test environment? What test environment?).The following was designed to obtain a number from the query string so it could figure out what product to display. Most seasoned .NET professionals would go right for Request.QueryString["number"];, but not this special snowflake:
The Coming Storm
As someone who has spent more than three decades working for all manner of huge financial-conglomerate IT departments, I've seen pretty much every kind of WTF imaginable. At every level. At every scale. For years, I chose to view it as getting paid for being entertained. But over time, it dawned on me that perhaps the reason these companies are so inept at IT is that they're so focused on the job of getting business done that they can't take the time needed to learn to think through a software development project in the way you need to in order to, well, develop software.This time around, I joined a fairly small financial firm that has a reputation for being fairly laid back. Most of the reviews by current and former employees stated that the management allowed them the time to (reasonably) properly plan out and run a software development project. I spoke with several managers, all of whom assured me that the project was reasonably budgeted for the appropriate folks (developers, QA testers, business analysts, project managers, architects, etc.). Requirements were being mandated by an industry edict. My role was simply to be one of more than 100 Java developers on the project.After two months on the job, it became clear that it was all a smoke screen.Apparently, while the industry edict was fairly specific as to what needed to be done, the business analysts and architects could not agree on how to do it. You see, the architects were drawing data flow diagrams showing what data flowed between what systems, and where things would need to change in order to implement the new requirements. However, the business analysts decreed that all of the old systems needed to go away and all new systems would need to be built.Naturally, the technical folks laughed raucously and pointed out that this would entail about 10,000 man years of effort, whereas simply augmenting all of the existing systems would take about 200 man years of development effort.The BAs put their collective foot down and refused to allow any architecture documents to be released to any of the teams. No new data structures would be specified. No interfaces between systems would be defined. Nobody would be allowed to start work building any of the components until the BAs were satisfied that what was going to be done would make them happy.This started about 3 months before I was hired, and went back and forth for about 5 months.Not a single page of documentation of what the new requirements were intended to accomplish, or how it would be done was distributed to any of the technical folks.After two months on the job, it was best summed up by this conversation (that took place over three weeks) with my boss:
Error'd: Piles of Unsanitized Clothes
"I'm not sure if the WTF is that I have to find 0000FF]2 piles of dirty clothes," Simon H. writes, "or the fact that the ']' makes it look like they entered the information in something resembling BBCODE."
CodeSOD: Listicle
The Top 10 Ways to See if an Item Is in a List, Only 90s Kids Will Get thisPardon the clickbait headline. We’re only going to look at one method to tell if an item is in a list. A bad one.Andrew M. inherited some software that tracks metrics. There are three general categories of metrics- “MS”, “FN”, and “CM”. Each of these categories contains a number of specific metrics, each assigned its own ID.So, the previous developer needed to write a function that answered this simple question: given a metric’s ID, is it an “MS”, “FN”, or “CM” metric?
Bring Your Own Code: Introducing the Lucky Deuce
The life of a developer is about being cunning. When presented a problem that could be solved with strenuous, character-building labor, our first instinct is to automate it and cheat our way around it, if at all possible.Or maybe I’m just projecting. Still, if there’s one thing I’ve noticed, TDWTF readers are a shifty lot of scoundrels. It’s time for us to put that cunning to work.Thanks to our sponsor Infragistics, for the next five weeks, we’re going to call upon you to build us a Scoundrel’s Casino. Each week, we’re going to introduce a simple programming challenge, and give you a few days to solve it. Each week’s challenge is independent of the last, and each week is going to be a little bit harder than the week before.And prizes? Prizes! The “best” entry each week, judged by completely subjective criteria, gets a spanking new TDWTF mug, a single-developer license for Infragistics’ controls, and some super-sweet stickers. There will be some additional prizes (more piles of stickers) for submissions that seem cool and fun. And most important, every entrant gets the best prize of all: bragging rights.The Lucky Deuce Casino You are a developer for an online casino, and thus a wanted criminal in the United States. While you hide from the FBI, your managers keep sending you requirement after requirement, with absurd deadline after absurd deadline. You haven’t even met the other developers on your team- you write one tiny module for the casino, and it gets taken away from you and bundled with modules written by programmers you’ve never met, and the end product is almost certainly a bug-ridden mess.You’re sitting inside a seedy motel on the outskirts of town. You’ve got the blinds closed, but that doesn’t stop the neon sign for the diner across the street from keeping you up all night. You haven’t gotten a decent night’s sleep in days. You’re wondering what you’re doing with your life, and how you can get out before you end up in jail, or worse. And then- DING! An email comes in, bearing the latest requirements for a new module. You’ve had enough of this. You’ll implement it, alright, but you’re not going to settle for the pittance of a salary they’re paying you. You’re gonna get what’s coming to you.The RequirementsThe first requirement is pretty normal. You’re supposed to write a module that generates random numbers like a double-zero roulette wheel. They don’t specify how the random numbers are generated, but that’s basically a single line of code. Super easy.It’s the second requirement that makes you groan with frustration. They don’t want the numbers to be really random. “In a true random sequence,” the write, “the same number may appear many times in a row, just do[sic] to random chance. While that is actually random, it doesn’t feel random to our players.” They want you to track a history of the random numbers generated, and make something that “feels” random: numbers that have appeared recently are less like to appear. “Runs”, where the same number appears 3 times in a row, should never happen.“Alright,” you say to yourself, “I can do that.” But you can do one better. In addition to implementing their requirements, you decide to add in your own. You’re going to write in a “cheat” function- something that lets you either enter in some sort of cheat code, or in some other fashion makes the output of the roulette wheel predictable. Be careful, though, you don’t want to get caught! You'll need to get creative to make sure nobody stumbles on your secret- millions of people are going to gamble with this program.Entering & JudgingTo enter, send an email to byoc15@worsethanfailure.com with a link or attachment of your code. In the body of the email, explain how your cheat works and what we need to do to run your code. You can use any language you like, but we have to be able to run it with minimal setup.You don’t need to build a GUI, but if you do, and you do it using tools from Infragistics, we'll send you a free license (one per entrant, supplies limited). Consider this your Infragistics bonus.Assume we have access to stock Windows, Linux and OSX instances, if we need to run your software locally. You could target MUMPS running on a mainframe, but we can't run it, and you probably won't win. You must get your submission in before 11:59PM Eastern Time, Sunday the 9th of August to be eligible for judging. We'll announce the winners next Wednesday, along with the next leg of the contest!The overall winner will be chosen by how interesting and fun we think their solution and cheat is.Thanks to Infragistics for making this possible.A worldwide leader in user experience, Infragistics helps developers build amazing applications. More than a million developers trust Infragistics for enterprise-ready user interface toolsets that deliver high-performance applications for Web, Windows and mobile applications. Their Indigo Studio is a design tool for rapid, interactive prototyping.[Advertisement] Scout is the best way to monitor your critical server infrastructure. With over 90 open source plugins, robust alerting, beautiful dashboards and a 5 minute install - Scout saves youvaluable engineering time. Try the server monitoring you'll 👍 today.Your first 30 days are free on us. Learn more at Scout.
The Galapagos
IT jobs are few and far between in the rural United States. Calvin considered it pure luck that he got a new job as a developer in his home town, a small Southern town of only 5,000 people. After a few short interviews, he gladly accepted the job, eager to give up his long commute to another city and stay close to home.His new company, ITWerks, was actually the former IT department of a local-but-large tractor company that had gone defunct twenty years earlier. ITWerks had managed to get spun off and survive on its own, handling general IT and development tasks for many other businesses in the area. The market was tiny, but competition was scarce, and since ITWerks was the sole vendor in its little corner of the state, it had little reason to change. Without any incentive to learn new processes and technologies, ITWerks became an isolated island of 1995 which was inexplicably transported to 2015.Calvin’s first task was to fix a few bugs in their web API. The API tied several different products together. He scheduled some time with Hank, the original developer, to get an overview of the product. Hank had been with the company for thirty years now, and hadn’t learned anything new in at least twenty. His overview was brief and uninformative.“I’m sure this API will look modern enough to you young whippersnappers,” Hank said. “Now, I originally done this in Visual Basic 5, but when C# came out, I decided to take a looksee and I rewrote this whole thing with C#. It’s been purrin’ like a kitten ever since. Anyway, all the source code is in a shared folder. Go ahead on and grab that, and let me know if’n you’ve got any questions.”“No source control?” Calvin thought to himself as he settled in at his desk. “In 2015? Source code in shared folders?” He shook his head and wondered what he had gotten himself into.He found the source easily enough… and was horrified at what he found. The API only had one class, called WebService.asmx, which was a hundred-thousand line monstrosity, all contained in a single source file. And though it was nominally written in C#, much of the underlying functionality was provided by old VB5 and VB6 DLLs, which the C# assembly called into using runtime-callable-wrappers.Calvin spent the next few weeks engaged in intense archeology. Despite the massive, convoluted, and uncontrolled codebase, he was able to find and fix the bugs assigned to him without too much difficulty. Late one morning, he met with Hank again to see what the deployment process was.“Deployment? We don’t really do no deployment,” Hank replied.“How do you put code into production?” Calvin asked, clearly confused.“Oh, that? You just need to build it, is all.”“What do you mean?”Hank laughed. “Bless your heart. I mean, in Visual Studio, go on up to the ‘Build’ menu, open it, and click ‘Build Solution’.”Calvin paused for a couple seconds to see if any sudden understanding would strike him. It didn’t. “Sure,” he said, “that compiles the code. But how do I deploy that to the web server?”Hank started to look annoyed. “Listen, you just build the solution, and that deploys it to the web server.”Calvin feared that he was starting to understand Hank, but hoped he was wrong. Hank excused himself to go to lunch, and Calvin headed back to his desk to check something.His suspicions were horribly, horribly correct. The network share Calvin had been using to work was mapped to a virtual directory in IIS. Calvin had unknowingly been releasing changes to production every time he pushed the “build” button- releasing code for an API that was used by several applications and a few dozen customers.Despite ITWerks being a WTF-filled cesspool of mid–1990’s development practices that were horrible even in the 90s, Calvin decided to stay. He has enough leeway to slowly drag ITWerks into the modern era. They’re now using Git and Continuous Integration on some of their projects, the deployment process now involves actually choosing to publish your code, and now there’s a test environment. Calvin especially enjoys his new commute. Instead of driving an hour each way to the big city for work, he gets home in about ten minutes to find his muddy kids running up from the creek in the pasture to greet him. That’s a fair trade in his mind.[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!
...5152535455565758