Feed the-daily-wtf The Daily WTF

Favorite IconThe Daily WTF

Link http://thedailywtf.com/
Feed http://syndication.thedailywtf.com/TheDailyWtf
Updated 2024-10-05 00:31
Classic WTF: Who Needs Connectivity? I Have Service!
Representative Line: Be Thankful for Good Requirements
In the US, today’s the Thanksgiving holiday. As I learned from A Charlie Brown Thanksgiving, it’s supposed to be about friendship, family, and being grateful for what you have. In common practice, it’s more about gorging yourself.While I was perusing our inbox, I saw that Matthew sent me a “flow chart” that represented a set of requirements from his sales team. Immediately upon opening it, I said, “Thank goodness I don’t have to work on this.”So, today, whether you celebrate the orgy of American excess or not, celebrate this fact. You’ve never been handed a requirements document this bad. I hope.[Advertisement] BuildMaster is more than just an automation tool: it brings together the people, process, and practices that allow teams to deliver software rapidly, reliably, and responsibly. And it's incredibly easy to get started; download now and use the built-in tutorials and wizards to get your builds and/or deploys automated!
CodeSOD: Mid-Stream Switch
Submitter James writes: "I'm working on a project that has as one of its components a Microsoft App for Excel 2013. My team lead wrote most of the app up to this point, and I'm adding features. While exploring her code, I ran into this little gem (in JavaScript):"
The Guru and The Code
A logistics company isn’t the kind of company that invests heavily in IT, no matter how vital IT is for their business. That’s why Rich spent several years as the only developer. Most of his code was built to pick up data from one siloed turn-key system and dump it into a different one, or to integrate two in-house developed applications. On a bad day, he had to touch up the VBA macros in home-grown Excel spreadsheet someone in accounting had hacked together and had suddenly become “business critical”.
CodeSOD: Confession: The Coin-Flip Hash
There are certain problems in computing that you generally shouldn’t tackle unless you’re planning to make it your life’s work. Don’t write your own date handling logic. Don’t write your own encryption. If you do, you’ll probably screw it up, so use something developed by someone who knows what they are doing. Handling passwords is a subset of encryption, in many ways. Samuel sends this to us as a confession- he hopes to unburden himself of his sins. It’s bad enough that he’s passing passwords in the clear, but he goes a step farther:
Error'd: End User Experience May Vary by Region
"I guess eight of the ports are English-only," Andrew G. wrote.
CodeSOD: The Cleaner
In software development, there are people who get the unenviable task of being the cleaner. Somebody makes a mess, and the cleaner comes in to take care of it. And that brings us to Tina.Tina was brought in as a cleaner. There was an application that was a mess, and the powers-that-be wanted it taken care of. Tina took a look, and she noticed that there were a lot of round trips to the database. In fact, after profiling, it almost looked like every query ran at least twice. She saw code following this pattern everywhere:
The Enterprise Axe
CodeSOD: A Hardware Switch
Michele S. had recently worked on code for an engine-controlled device. Since the device had physically-moving parts operated by servos, the software had to be careful to not move anything out of bounds because it could actually break a physical piece of equipment.Michele had written the low-level function which sets the position of a component.
Quality Overhaul
"Hey, did you see the email? They're remaking our website!""No way, Dave. You're kidding." Cody rushed to his PC and opened the latest company newsletter. After three years of working at IniVenture, he found the news hard to believe. Despite many pleas from the employees, management had never dared to touch that relic of late 90s web design, opting to spend their time and money on more lucrative ventures instead."'Over the next few months,'" he read aloud with Dave peeking over his shoulder, "'we'll be cooperating with Victory Design, an award-winning web design and development agency, to bring IniVenture even closer to the world of Internet and modern technology.'""As if we were anywhere close to that now," Dave groaned, then took to hunting the usual bull. "Let's see: 'latest technologies,' 'brand synergy,' 'your feedback matters,' blah blah blah ... " He smirked. "Well, I don't know about you, but I can't wait to see the revamp. It's going to be a beautiful disaster."Months passed without any news about the new website. Some employees sent their suggestions and offered help, only to be met with a standardized response and no follow-up. The newsletter didn't offer many updates either, other than the occasional reassurance that the project was "right on track" and would be completed "shortly." Reading between the lines, it seemed the revamp had either been shoved aside or canned.Until one day, Cody ended up paying a visit to the IT department."Hi, Jen," he greeted the mousy girl tapping at the keyboard. "Can you hook me up with a clean laptop? We have a new guy starting in a few days.""Uh, yeah, sure, but it'll have to wait a while," she said, not lifting her eyes from the monitor. "I'm just deploying the new website, so ...""Oh, it's done already?" Cody asked, surprised. "Is it any good?""I ... don't know, really," Jen answered. "I didn't even have time to look at it. The moment the PM got the first version from the designers, she forwarded it to me and told me to put it on a public server immediately.""Wait, seriously?" Cody's eyes went wide. "Aren't you guys going to, um, test it or anything?""I tried to explain, and the other company did too, but ... well, let's just say I got my orders." Jen shrugged and went back to hacking at the keyboard."Well, good luck then."Cody sneaked out of the room and went back to his desk. Wow, what a mess, he thought. It's probably going to be down for at least a week, maybe more.But he turned out to be wrong. Just an hour later, his browser opened to the new, sleek, and remodelled IniVenture home page.Except the more he dug into it, the more problems he found. Some links lead to 404 pages, others went into infinite redirect loops. A few images and captions were missing. And to top it off, most projects and clients were just test data left over by the developers, all of them located in "SAMPLE City, SAMPLE State, US".Trying not to laugh, Cody clicked the "Employee Survey" link to let management know about the issues. The page promised that every employee who offered his feedback would be entered into a drawing to win a new iPhone. He answered the questions eagerly but honestly, describing his findings in detail. Then, when the last field of the form asked him to provide his name and email for the sweepstake, something dawned on him ..."Hey, did you see the email? Guess who's the lucky guy with the new iPhone?""What, did I win?" Dave ran to Cody's desk and peeked over his shoulder. Trying not to laugh, Cody pulled up the latest company newsletter."'The new website proved to be an amazing success. We'd like to thank everyone for their efforts, and we'd like to thank over 17,000 of our employees for taking the time to voice their feedback.'""Wait, what?!" Dave cried. "We don't even have a tenth of—""Read on." Cody buried his face in his hands to contain the laughing fit."'The lucky winner of a new iPhone 6S is Mr. Bruce Wayne, who can contact our corporate offices at Gotham City to ...'" Dave shook his head. "Great. Now we have Batman working for us?""Either that, or someone failed to make sure that the employee survey was for employees only!" Giggling like a madman, Cody closed the email client.It wasn't until the following month that management figured out the problems with the website. They ended up taking it down for a month of maintenance, then silently replaced it with the old version.And as far as everybody at IniVenture knows, the Dark Knight never showed up to collect his iPhone.[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: Who Stole the Search Box?!
"Why, thank you, Microsoft, I do need assistance with... wait a minute!" Steve L. writes.
Your Recommended Virus
In the early 2000s, Fernando was the Network Operations Manager for a wireless ISP known for its comprehensive customer support. They had techs who’d install the necessary gear, and consultants who’d arrive onsite to reconfigure computers, routers, firewalls, and everything else, until the customer was completely up and running. A small team of developers could even custom-build any small software apps a customer might ask for.The service was well loved. In fact, it was so thorough and helpful that after the initial install hiccups were soothed, Fernando and his support team almost never heard from customers again.“We’re too good!” a sales manager complained during one of the most surreal meetings of Fernando’s career. “We’re hurting our own business! There’s gotta be a way for us to drive up service calls!”“Ethically,” another sales-beast added quietly.“Right, ethically. What can we do?”Brainstorming commenced. A set number of service calls that the customer had to pay for upfront, whether or not they were ever used? Quarterly “check-ins” built into everyone’s service contracts (at a price, of course)?“Hang on, this is still about helping our customers, right? Or at least it should be,” Fernando said. “What’s one thing that everyone needs help with, all the time? Security. New threats pop up all the time. Why don’t we set up a listserv that we can use to recommend security updates and best practices? That way, we’re staying in touch with the users with good advice—and we can encourage them to call us for help with implementing that stuff.”It was a fantastic suggestion. The sales managers were happy. The top-level execs were happy. And since it had been Fernando’s big idea, he had the privilege of implementing it. He set up a Majordomo list-server, configured to accept postings from his email address only, then carried out his plan to great success. Customers received highlights from Bugtraq and other relevant sources, generated steady business, and were protected from many nasty problems.Everyone was thrilled.It took a full two years before the storm clouds surfaced, but surface they did. Bafflingly, Fernando received an email from the listserv that he hadn’t sent. He opened it, and slowly realized what he was looking at. A Windows virus from some customer's site had replied to one of his emails, and had used his email address as the forged sender. His list-server had then dutifully forwarded it to the entire distribution list.Horror shot through him. Not two seconds later, the phone rang.“Hi Fernando, it’s Brian. Listen, I just got your email. What do you need me to do with this here?”“I’m sorry, it was a mistake,” Fernando gunned out, heart pounding. “Please go ahead and delete that.”He was hardly off the first call when the next one came in. While he was on the line, he watched emails pile up in his inbox.I don't understand what you mean by this.Am I supposed to install this?Can you have one of your guys come out and install this for me?Fernando shook with terror. Sweat beaded at the nape of his neck. Hundreds of customers could potentially infect and torpedo their own operations, all because the Network Operations Manager in charge of security emails had just sent out a virus.The next free moment on the phone, he called his receptionist. “Hold all my calls for the next few minutes, please.”Before he heard any acknowledgement, he dropped the phone back into its cradle and began drafting a clarification email to explain the whole mess. Please disregard—“Hey, what was that weird file you sent out?” A coworker leaned lazily past his office door. “Looks kinda suspicious to me.”“I’m aware of that.” Fernando struggled not to curse or yell. “We’ll talk later.”Once he’d sent out the email, he firewalled the majordomo process to only accept email from localhost. Then he sat back, closed his eyes, and prayed.His quick action made more of a difference than any divine intervention. Fernando never heard any reports of customer systems getting infected from that incident.Disturbingly, he also never figured out whose machine had sent the original.[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: Confession: rect.Contains(point)
A few years ago, Josip M decided to try his hand at building games using C# and the XNA framework. He started implementing the classic board game, Nine Men’s Morris, but like most side projects, he lost interest and mostly forgot about it… …until a few months ago, when he started cleaning up his hard drive, and found the code again. Then he remembered why he lost interest and abandoned the project:
Single-User Mode
It was a common occurrence for Jarosław F.’s brother, Andrzej, to call him for help. Andrzej worked as a data-entry specialist for the Polish Ministry of Employment, while Jarosław was part of the ministry’s IT department and moonlighted as a Python programmer.One day, Jarosław answered another call from Andrzej. “No sane person can do this job,” Andrzej started. “There just aren’t enough hours in the day.”“‘Hours in the day?’ You enter data and run reports using web software. It’s not that difficult.”“No, you don’t understand. The ministry’s starting a new labor force program, and I’m in charge of the data entry. But there are too many records to enter by hand.”“Andrzej, I’m really tired of this,” Jarosław said. “I’m going to write you a script to help with your work, and in exchange you don’t call me at work for six months. Deal?”Eternity in a CellJarosław had never actually seen the software Andrzej used to enter data. Just getting to Andrzej’s department required signing an authorization form at the front office, then a half-hour wait until his supervisor gave the go-ahead. But Jarosław knew writing the script for his brother wouldn’t take very long.Andrzej showed Jarosław to his desk and opened a browser. The web application looked current circa 1998, as if someone mocked up a Windows GUI in Internet Explorer 4. There were rows and rows of grey tabular data, text set in black Tahoma. Next to each cell was a button marked Edit.“You press the button to edit each cell, which takes a few seconds to load,” Andrzej said, demonstrating. “Each cell, and every row, must be entered one at a time”“Surely there’s a ‘bulk import’ somewhere.” Jarosław scrolled down the page, looking through buttons labelled Income Report and Demographic Report. There was nothing marked that looked remotely like a bulk import feature. “How long does it normally take you to enter a row?”“Five minutes. I usually get about 10 records an hour. There are 400 records, and my boss needs them done by the end of Sunday.” That left five days. “I still have reports to run while I do this. That’s why I need your help.”Parallel Punishments“Okay,” Jarosław said, “can’t you get someone to help you with this? Five people entering data would mean it’d get done in a day.”“Even if we had that many people to spare, there can’t be more than one person entering data at a time. The system would crash.”Jarosław chuckled. “Oh, come on. No web application forces a single user to enter data.”“A year ago, we tried using two people at a time,” Andrzej whispered. “A whole dataset was corrupted. It set back the department’s mandate by six months, and my last supervisor was fired because of it. My new supervisor won’t tolerate any further delays.”A CRUD-like web interface, with no parallel data entry allowed, it seemed deliberately designed to make one person’s life miserable … and that person was Andrzej.“It’s a good thing I work in IT,” Jarosław said. “Because what you need is a tailor-made import script, and I’m the one who can write it for you.”Automated Manual EntryFirst, Jarosław installed Python on Andrzej’s computer. If Jarosław were about to exploit the ministry’s applications, he wanted to use a language he was familiar with. Next, he entered a few sample rows from the dataset Andrzej was burdened with. He logged every HTTP request the web application made, making a list of calls his script would need to make. Finally, he converted the Excel file the data came in to .csv so his script could consume it. It was tedious, but not as tedious as Andrzej’s burden.“Let the script run overnight,” Jarosław said. “If anyone asks, tell them I did this on my own initiative. It should be done by morning.”The next morning, Andrzej himself went to see Jarosław in the IT department. He looked relieved. “You just saved me four days of manual data entry.”“You can use it on other datasets,” Jarosław said. “Just convert the files to .csv and pass in the filename as an argument from the command line. And make sure no one else is entering data while it’s running.”“Thanks,” Andrzej said. “So, call you in six months?”Jarosław shook his head. “This one’s on me. I had no idea what torture they put you through until you showed me.”[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!
Announcements: Bonus WTF: Karmic Cascade
Our sponsors at Infragistics have a special treat over on their blog: an extra feature for today. It's a story of teamwork and "teamwork", and of course- disaster.Check it out.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.
CodeSOD: All Wrapped Up
PHP has a lot of warts, and one of those warts is its approach to database interactions. If you want to talk to a MySQL database, every function for doing it is prefixed mysql_, and for say, Postgres, you’d use functions prefixed pg_. On the other hand, it uses an object oriented approach for talking to SQLite3, while Oracle not only has a set of oci_ prefixed functions, but has to add a bunch of important functions that make it just different enough as to be difficult to switch to.It’s a bit of a mess, is the point, and the result is that a lot of developers will write some wrapper functions to make it easier to write generic code that’s not tied to a specific database engine. That is, presumably, what Scott’s co-worker had in mind when building this library of wrapper functions:
Error'd: In Memoriam
"I went to get my stuff off the printer at work but it appeared to have passed," writes Kelly B..
Featurette: Puppet Labs
As we announced a few months back, Puppet Labs is one of our sponsors. As part of that arrangement, I got to go behind the scenes and learn a little bit about how things work at Puppet Labs.I got to have a conversation with Stephanie Stouck, a product marketing manager, as well as Eric Sorensen, their technical product manager. Eric’s a long-time sysadmin who migrated from being a customer of Puppet and its competitors into being someone who makes Puppet. Stephanie comes from a background in product marketing, but gets to see how customers are using Puppet.Before we get into that, though, let’s get the important question out of the way. Puppet Labs is based in Portland. How’s the office coffee? “Delicious!” according to Stephanie. “We have a kind of ridiculous coffee culture,” Eric says. “I feel at least partially responsible.” He should- he’s the star of Puppet’s internal training video on how to care for their espresso machine.Puppet is one of the big products at the center of the “DevOps” space. DevOps, like “the cloud”, and “agile”, is a term everyone uses, but no one can accurately define. I gave Stephanie and Eric a chance to nail the term down.“DevOps is as much a cultural shift,” Stephanie explains, “as it is a set of work practices.” It’s not a specific set of tools, techniques, or practices, but more a goal: “DevOps means development and operations teams are aligned around a single business goal- to deliver value to customers.”Eric expands on that alignment. “It’s sharing technology that’s taken for granted on one side of the dev/ops divide and implementing it in a new way… for example, bringing pervasive version control and CI from the dev world and applying it to infrastructure code; conversely, taking the idea of monitoring every metric and instrumenting the application to expose those metrics from day one.”This all feels very warm and fuzzy, but let’s get down to brass tacks. I don’t want to end up being the subject of an article on TDWTF. How does Puppet help with that? Eric has a strong opinion:
CodeSOD: Circle Space
Self Service
Anna’s employer made billing software for energy companies, and they had just entered into an exciting time: the Dutch utility market was loosening its regulations, and that meant a flood of startups were looking for a cheap way to bill their customers. Of course, their product was designed for the US market, not the Dutch market, but the CEO didn’t see that as a problem. “No worries,” he would say, “Anna’s our top notch configurator, and she’ll customize it for you in no time.”This, of course, was news to Anna, who didn’t actually know anything about the configuration of the software. After a one-day training session, she was officially declared the “expert”, and sent off to sink or swim- and she mostly swam. There were a lot of options in the package, and it was extensible through add-ons, which meant Anna spent a lot of time whipping together one-off modules for each customer’s deployment.During this period, one of her “favorite” customers was Joep. Joep had needs. Joep had a lot of needs. He was polite, and friendly, and Anna liked Joep, but Joep tended to start every conversation with, “You know, it’d be nice if…” and then invent a thousand new requirements for the billing package.A lot of them were around reporting, which was not the system’s strong suit. Joep wanted the ability to run ad hoc reports against any dataset his mind could imagine. “How many left-handed customers logged into the billing application between 2:04AM and 2:37AM and were also watching something on Youtube?”This lead to a lot of screen-sharing sessions and on one of those calls, Anna fired up Toad to connect to the back end database.“Oh! What’s that?” Joep asked, as she typed in a query.“I’m just trying to see if we’ve got the data we’d need to build your report.”“And you can type commands… to build custom queries?”“Yes…” And Anna was seduced by temptation. Joep wanted a lot of custom reports, and if she showed him how to use Toad and introduced him to basic SELECT statements, he’d be able to “self service”, and that would save her a lot of headaches. So Anna helped him install Toad, disable the auto-commit functionality, and showed him how to write SELECT statements. Joep was happy, and Anna fielded far fewer calls from him.Time passed. Anna moved on to work with other customers, Joep changed jobs, and roughly a year later, their paths crossed again. Anna’s latest client was Joep’s new employer. They shared a laugh, reminisced about old times, and then talked about Joep’s new needs.This time, they had a SQL Server back-end, which didn’t really change much about how the billing package worked. Anna noted that, and started gathering requirements for the new batch of add-ons and custom screens she’d need to build. While she was concentrating on that, Joep asked, “I was looking at SQL Server, and Microsoft’s management tools look even nicer than Toad. Do you think I could use those?”“Sure, I guess,” Anna said, without really thinking about it. Over the next few weeks, she got Joep’s new company set up and configured to their liking, and moved on to the next client.Months later, this email arrived:
CodeSOD: Bonus WTF: Happy Birthday, George Boole
Today is George Boole's 200th Birthday. We've rerun this classic many times, but I can't think of a better time to reshare it! - RemyThe problem with "logic" is that it makes things out to be nothing but simple dualities. Proponents of logic want us to believe that everything is true or false, black or white, yes or no, paper or plastic, etc. Thankfully, there are some among us, like Mark Harrison's colleague, who are not afraid to stand up to these logic advocates and shout "no, I will not succumb to your false dichotomies!" Today, I think we all should salute those few brave people ...
CodeSOD: Shadow Over XML
Halloween may be over, but it’s always a good time for a horror story.Like many horror stories, Nick’s starts with a mysterious inheritance from a long-gone predecessor. This tool manages student data, and it needs to pull data from documents in Microsoft Word XML, using C#.The escalation of any horror story moves in small increments. First, you notice things that are a little off, like this method signature:
Error'd: Schrödinger's Tortoise (SVN)
"It's curious that SVN is simultaneously both clean and unclean until the computer is restarted," Hesham M. wrote.
CodeSOD: Leading Development
H. J. works in a place where best practices are known, but bitterly opposed. You see, they have a lead developer who is more experienced than the rest, and it is his mission to show the others how things should best be done. Some of his finer resume-worthy accomplishments...
Tales from the Interview: Monitoring the Situation
Joe T recently decided it was time to go job hunting. This mostly meant deflecting emails from head-hunters, doing phone interviews with ignorant HR departments, and the occasional on-site interview with a possible employer. One of those on-site interviews brought him to an IT services company which handled a few large US government contracts.The building itself was buried way in the back of a tech park, behind a small pond inhabited by ducks and migrating geese. It was modern, in a circa 2002 way, gleaming white, with a large and mostly empty parking lot, and a glossy lobby and a pair of cheerful receptionists.One of the receptionists made a call. A few moments later, Ricky, Joe’s contact, stumbled out of the elevator. He had the look of a man who hadn’t slept in a month. As they piled into the elevator, he said, “We are really eager to fill this position. Just between you and me, I think you’ve got it sewn up, but you need to meet the team.”Ricky led him into a conference room, where a few other sleep-deprived looking techs nursed their coffees. After a round of handshakes, they dove into a series of sysadmin/operations questions. Some of them were just dumb trivia: “What’s the purpose of the -i flag on the ls command?” Some were dumb soft-balls: “What time management techniques do you use?”After the warmup, Ricky leaned forward, and got right to the meat of it. “You’ve got three data centers,” he said, “how would you monitor all three of them?”That was a vague question, so Joe could only give a vague reply. “Well, I’d imagine all three are connected to the same management network. So I’d run some sort of monitoring package on that network.”“You don’t have that,” Ricky said. Joe couldn’t be sure, but he thought he might have seen a grimace on the face of one of the techs.“Well,” Joe said, “then we’d just have to set up monitoring in each DC independently, and then aggregate somehow, but that’s really not the best option. Setting up a management network is-”“Ah,” Ricky interrupted, “but what if you don’t have the budget for any monitoring software?”Joe, sitting in the middle of the interview, jumped to a conclusion about Ricky’s line of questioning. This was one of those old interview tactics: no matter how the candidate replies, throw up an obstacle, and see how they can “think outside the box”. This was just a bizarre hypothetical situation. He played along. “I guess we’d need to install Nagios or some other open source monitoring tool.”“The customer doesn’t allow any open source software on the network,” Ricky countered.“None?” Joe asked. “But don’t you have some Linux servers?”Ricky nodded. “We do. But no open source software on the network.”“Well, I mean, if you can’t buy software, and you can’t use free software, you can’t really do any meaningful monitoring.”Now Joe was certain: the techs were all grimacing, and oh so very slightly nodding along with him. This was what they expected him to say, but Ricky wasn’t going to give in yet. “Now, you can’t just throw your hands up and say, ‘It can’t be done.’ You have to monitor these datacenters, so what do you do?”“Well… I mean, at that point, we’re just writing our own scripts and running cron jobs. But that’s a totally ridiculous scenario. No one would actually run a datacenter that way!” Joe punctuated the statement with a laugh, because obviously this was all just silly.No one else laughed. Ricky’s line of questioning wasn’t a hypothetical, it was an accurate description of their infrastructure in their datacenters. After a solid minute of awkward silence, Ricky started asking questions about the previous jobs on Joe’s resume.Somehow, Joe left the interview with a job offer, but he politely declined.[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: The Hard Problem
I’ll warn you to start: this is a date handling CodeSOD, but that’s only a small part of the WTF. You see, there’s an old joke, “There are three hard problems in computer science: naming things and counting things.” This code has a hard time with the first:
Just Following Instructions
Cameron was a support rep for a Unix-based software package that had also been ported to Windows and Mac OS X. He supported every version, and quickly learned that not all ports were created equal.The Windows port was the angel of the pair. The developers had written an installer with NSIS that created an icon on the Desktop for users to double-click. It worked well enough that Cameron almost never fielded Windows install support tickets.The Mac port was the devil from a support standpoint, and there was really no good reason for it. As long as Xcode and X11 were installed on the user's machine, everything worked perfectly. However, few Mac users had these libraries out of the box.No problem. On their product download webpage, they supplied links not just to their own installer, but also for the Xcode and X11 installers. And yet, the number of users calling in to flail helplessly were numerous."What link? I don't see it anywhere!""The installer's on another site?""What do I do now?"When Cameron walked users through the process verbally, it always went fine. He got so much practice at it that the instructions were practically encoded into his neurons.One day, Cameron had a sanity-preserving idea. He ran it past his boss, who then set up a meeting with the product website masters."We field a ton of calls for this Xcode and X11 install stuff," Cameron explained. "No one can figure it out without some help. I'd like to set up a webpage describing the whole install process step-by-step. I think it'll really cut down on the confusion. I know HTML, I can put the page together myself with screenshots and everything."Everyone agreed it was a good idea. After some minor negotiating, the web team agreed to give Cameron access to the product website's test domain. "Write up the page you want. Once you get it how you want it, we'll QA it, then promote it," they told him.The opportunity to do something outside the same old support work was exciting to Cameron. His HTML experience came from all the personal websites he'd thrown together since the days of Geocities, and wasn't too shabby. He put together a nice step-by-step breakdown, describing every detail of going to the appropriate external website and running the installers, with screenshots and links to everything the users would need. In the screenshots, he painstakingly indicated each button and link to click with little circles and arrows.His boss liked the page, praising his "moron-proof," thorough instructions. The page went live soon after. Cameron looked forward to spending more time on more challenging support tasks.A few months later, he resigned himself to the bitter reality that nothing had changed. It seemed no one on the planet could perform the Mac install unassisted. He fielded calls from end users all the way up to "network administrators" and "tech professionals.""It doesn't work for me! Nothing happens when I click the links!""I followed your instructions to the letter, but the icons didn't work.""Nothing happened."Strangely, each time Cameron walked someone through the process, everything went fine. He couldn't understand it.Neither could his boss, who wanted to reduce this pain point for his support staff. He approached Cameron one day with a suggestion. "Hey, we're doing a trial of this new remote viewing tool. It'll let us see exactly what users are doing, and dig into their systems directly if we have to. Would you like to try using it to see what the deal is with these Mac installs?""Sure!" Cameron was willing to try anything.It didn't take long for another call to test on. "When I click the icon, nothing happens," the user explained to Cameron."All right." Annoying, but old hat by that point. "I'm gonna email you a link to a remote viewing session. This'll let me watch your install process. Can you click that link when you get it?""Sure."They were connected a few moments later. The man's kitten-festooned desktop filled Cameron's view."OK, can you go to your browser and walk me through what you're trying to do?" Cameron asked."OK." The user opened up a new browser window and clicked a bookmark in the toolbar. "First, I go to your product page."It loaded obediently a few moments later."I go to the instruction page …" He clicked the link to Cameron's how-to page. "Scroll down here a bit … then I click this icon, and nothing happens."Cameron looked on in mute horror as the user furiously clicked a screenshot displaying the X11 icon with a circle around it. The 3x3-inch screenshot that he'd been careful to label "Screen Shot" in big letters."Oh. Uh …" Are you kidding me? This is what everyone's doing?! Cameron took a deep, calming breath before continuing. "That's not where you want to be clicking. Just a little higher than that is a link that says ‘Click here to open the Xcode install page in a new window.' Can you try that one?""OK." The user complied, and the Xcode site loaded obediently."There we go!"Cameron had no trouble walking the user through the rest of the process. Afterward, he sat back with a frown, thinking. Should he remove the screenshots? No, they were important for illustrating what to do on the Xcode and X11 websites. There was a better way to handle this, he was certain.He took to Google. After a little research on Javascript onclick events, he contacted the web maintenance team, describing the change he wanted to make.Sure! they emailed back. Do it in test and tell us when you're done.From there, Cameron added a script to his webpage so that whenever someone clicked on any screenshot, a window popped up that read, "You are clicking on a screenshot within our instructions. In the Xcode/X11 website, find the window that resembles the screenshot and click on the icon there."[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!
Error'd: Google's Time Travel Shenanigans
"10 minutes is pretty reasonable, but I don't think that I'm going to make my connection 2 minutes in the past," writes Rich H.
CodeSOD: A Well Mapped Error
Marvin’s company had a problem. Their C++ application tended to throw out a lot of error codes. That was actually okay- that application had a lot of possible failure modes that it couldn’t do anything about other than cough up an error and quit.The problem was that their customers weren’t particularly happy with messages like: Error: QB57, since it told them absolutely nothing. “RTFM” was not an acceptable response, so someone had to add some functionality to turn those cryptic error codes into meaningful messages.Since it was a simple job, they handed it off to the co-worker who nobody really thought all that much of. He was a terrible programmer, but how badly could he screw a simple map/hash/dictionary problem up?First, construct the data structures to hold the error messages:
Apache Chief
W.T.F. Community College hired a team of highly-recommended web design consultants to bring its website in to the 21st century. Paul was tasked with overseeing their work and supporting the new site upon go-live. After a couple months of grinding, they cranked out a beautiful new site that was accessible, navigable, and responsive. It also removed the old site's dependence on Flash, replacing it with a titanic mound of PHP and JavaScript that was run by Apache. Paul and his team gave it a thorough beating in their test environment and everything seemed solid. They even gave a demo of it to the the head of W.T.F. Community College, President Skroob. He was able to easily find his way around, sign up, set his password to 1-2-3-4-5, and register for fake classes. It got the Prez's official salute of approval. The amazing new website was ready to be launched in time for the fall semester.The first day of classes rolled around and suddenly everything didn't seem so rosy. President Skroob frantically burst in to the IT office shouting "The web site is down! The web site is down!" A quick check of the monitoring system didn't show anything wrong, and manual inspection didn't either. The server hosting the site was hardly breaking a sweat. No pressure on CPU, RAM, or I/O. Paul tried browsing to the site and the browser just hung. No errors, no nothing."Well that's interesting," Paul said to no one in particular. "We've lost the bleeps, the sweeps, and the creeps.""Why don't we try restarting Apache?" one of Paul's cohorts suggested. Paul shrugged and did so, and the website immediately returned to normal."I don't know what old Indian tribes have to do with our web site, but I'm glad it's working now!" President Skroob stated before ducking out of the office.Paul set up a simple monitor to hit the home page every 5 minutes to make sure the problem didn't return. But an hour later, the alarm went off. He restarted Apache quickly, and things cleared up. So began a nightmare where someone from Paul's team always had to be available to restart Apache once the website hung. The Prez was not pleased."Get a hold of the Apache Chief who made this website and get them in here to fix it NOW!" Skroob shouted at Paul.Paul got on the horn to the consultants, who hemmed and hawed about checking their code. If they were to be brought back in, it would cost W.T.F. CC an exorbitant sum. Paul decided to look more closely at the server first, and found Apache was running out of processes. He increased the MaxProcesses limit which bought them some time before the site would hang again. All processes were stuck in CLOSE_WAIT status, meaning the client browser had closed the connection but the server hadn't.A system call trace on a stuck server process showed it was waiting on a file lock, and a stack dump showed the culprit was `mod_php`. Since they were waiting on a lock, they were suspended and couldn't exit. In fact, all the dozens of stuck processes were waiting on the same file: `/var/lib/php/session/sess_111`.Paul got back on the phone with the consultant team and learned the story behind this big WTF. The new website had feeds (such as current events and the faculty directory) that could be updated dynamically and might be accessed from any session. But to avoid regenerating the output HTML on each load, it was cached so every PHP process could get to it. The consultants had done this using a single, global, monster PHP session.Thus, every website hit required a server process to read and write that one session, thus locking the session file. If new requests came in at Ludicrous Speed, they were unable to get through the bottleneck and eventually Apache couldn't spawn any more processes. At that point, the site would go catatonic to the user."Guys, this is in no way acceptable," Paul berated Apache Chief & Co. "You need to find another approach to caching the data." Meanwhile, Paul wrote a workaround script that ran once a minute and restarted Apache if there were too many stuck processes. Two weeks and thousands of dollars later, the consultants ameliorated the problem by dividing traffic amongst four different cache "sessions".It worked well enough that Paul's script only got triggered during extremely high usage times. Even then, there was very little downtime. President Skroob put the kibosh on any more of the school's Space Bucks going to the Apache tribe, so getting them to develop something that wasn't just a hack job was out of the question. As long as it worked most of the time and kept Skroob out of their office, Paul was comfortable with leaving well-enough alone.[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: Sort, Then Add, Forever
Go-live day for the new CabinetWorld redesign was a tense, hurried affair. Developers streamed in at 5:00 AM, hoping to catch wind of early problems before most of the country awoke and started shopping. True to form, the overworked break-room coffee machine gave up the ghost at 5:10, but luckily, at 6:00 the boss brought in doughnuts, and by 6:30 a Starbucks run had been arranged. Everyone huddled in the war room, nervously watching the monitors as the number of concurrent visitors rose steadily. And then ..."Why's it slowing?" Ashley whispered, not wanting to cause a panic.Dave stuffed the rest of a cruller into his mouth and looked where she was pointing: one particular API service was buckling under the so-far moderate load. Oddly enough, this wasn't part of the overhaul. This service, which merely returned a product list, was a legacy service they'd switched to using, one that powered their own internal tools. It should've been nice and stable—but instead, it chugged along like it had eaten a few too many doughnuts itself.Dave grabbed the source code while Ashley combed the production logs, looking for the source of the slowdown. "Crap," whispered Dave, noticing the version control history. "That's Bruce the Intern's work."Bruce had been the "clever" intern the summer he'd worked at CabinetWorld, the one they'd assigned actual coding tasks to. Unfortunately, he'd been too clever for his own good, as the code revealed:
An Efficient Curmudgeon
One of the things a good developer should always strive for is efficiency. Slow code should be improved if possible. Complicated steps should be simplified or removed. Finding a poorly-implemented process which is costing company time and streamlining it is usually a good thing, and means more profits, which means larger paychecks and bonuses, and happy bosses. Right?
Error'd: For Quality Assurance Purposes
"I don't work for them, so when did it become my job to do their quality control?" writes T. K.
CodeSOD: Validate My Feelings of Cleverness
It’s not uncommon to have a branch in your code along the lines of, if (debugMode) { doSomeLogTypeThingy(); }. Usually, we try and wrap that sort of stuff up and keep it far away from the actual business logic, and the result is a plethora of logging frameworks and diagnostic libraries.They are, however, consistent about one thing: whether or not debugMode is enabled or not, the actual business logic should behave the same way. They’re designed and intended to be minimally disruptive.Remco found this method:
Filing Data
Databases are wonderful things. They help you organize your data at multiple levels. Large logical units of data are stored in databases. Smaller logical divisions are stored in tables, and individual records are stored in rows. Once you have your data stored like that, you can access it in all sorts of wonderful ways.Of course, there's more to it than that. Beneath the database is the file system. Beneath that, there are one or more drive arrays each with one or more disk drives, each with one or more platters. Read/Write heads move back and forth to access the data on those platters. All sorts of sophisticated mechanisms have been developed to minimize the dead time of having a head in the right place, but waiting for the platter to spin the data beneath it for retrieval.DBAs take this into account when defining where the database and included tables will be stored. For example, they shouldn't put two databases (for different applications) that require extremely high rates of access on the same disks so as to minimize contention, because a head can't be in two places at once. Sometimes, they'll stripe data for a single table across multiple spindles so as to minimize hot spot activity by hashing the data across partitions.Mr. Anon. works with a DBA who believes that there is a better approach. Each database should contain one table. That database should reside in its own data file on the disk. Accordingly, there were thousands of data files. Since the operating system has a limit on the number of open file handles, the data server could only access so many databases at one time. The underlying theory was that this would reduce contention.However, since the files are stored all over the disks, the heads-can't-be-in-two-places-at-once issue still causes problems. Since a table/database is stored in a single file, it's no longer possible to stripe it (as one might with partitions). Also, since the data server can only open so many file handles at once, in order to open more, it must juggle opening and closing database file handles. As one might expect, this overhead is substantially noticeable.Of course, there is the maintenance side of things as well. Changing the log segment of a 200 table database is basically a one-off action. Doing it for a database that is stored as 200 separate databases of one table each now becomes a significant amount of effort. It's still O(n), where n is the number of databases, but now it's a huge effort. The same goes for every other database-level attribute.A more interesting facet is that now it's possible for only one table of your database to go down while all the others are happily processing requests. Now you need to code multi-table inserts as multi-phase commits.Equally interesting is how one might code a join of n tables, when it's possible that zero or more of them might be in databases that are unavailable. Hmm?All of this was rationalized as acceptable because it was all to support a web application, where performance didn't matter.Ah well, at least this way you know you'll never find a database with thousands of tables in it.[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!
Coded Smorgasbord: A Type of Insanity
Types are fundamental to most programming languages. Even the loosest, duckiest type system is still a system of some kind. It’s impossible to be a programmer if you don’t at least have a vague understanding of what types are, what they mean, and how you use them.Well, not impossible.The Null TypeKelly came across some C# code that needed to take the value in one variable (which may be null), and store it in the property in an object. Instead of writing the obvious statement:
Run Crash Crash Run
As Max entered the room, he was instantly greeted by a scorching wave of heat.As it turned out, even the freezing Russian weather was no match for the boiling hot atmosphere at Sturmovik Games' office. The small Moscow-based company with a humble portfolio of mobile games was just days away from a major content update for one of them. Naturally, the whole place was on red alert. Said update had been in the works for over six months, and had been widely advertised as the greatest overhaul the three year-old game had ever seen.During those six months, Max and his two coworkers put in an insane amount of work, implementing the ever-changing feature requests, writing and rewriting swathes of code, and fighting against the buggy third-party libraries they had to use. Finally, the stress and overtime hours were about to pay off. Every deadline had been met. All they had to do was deploy the update.Or so Max thought. The booming voice behind him brought him back to harsh reality."Who broke the build?!"The dreaded question hung in the air. Max turned to find Ivan, his fellow developer, standing and looking around the room to find the culprit. With the third developer on sick leave, there weren't many other people to whom the question could be addressed."What do you mean?" Max asked. "It worked yesterday, and ..." He trailed off when he noticed an email that had just arrived in his mailbox:
Error'd: Installing Flash Player is Hard Work
"Installing Flash Player sure is hard work," Mike H. wrote, "good thing that Adobe suggested taking a bit of a break afterwards."
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."
...444546474849505152