Feed the-daily-wtf The Daily WTF

Favorite IconThe Daily WTF

Link http://thedailywtf.com/
Feed http://syndication.thedailywtf.com/TheDailyWtf
Updated 2024-11-23 05:16
Representative Line: Off in the Distance
Drew W got called in to track down a bug. Specifically, their application needed to take a customer’s location, and measure the distance to the nearest National Weather Service radar station. It knew the latitude and longitude of each, and needed to find the distance between those points, and it was wrong. It could be off by hundreds or even thousands of miles, especially in more remote locations.This was the code in question:
The Infrastructure
George had just escaped from his job, a WTF-laden hellhole where asking for a test database to reproduce an issue resulted in the boss spending hours and hours hand-typing and debugging a fresh SQL script based on an old half-remembered schema.Initech promised to be a fantastic improvement. “We do things right around here,” his new boss, Harvey, told him after hiring him. “We do clean coding. Our development systems and libraries are fabulous! And each of our programmers get a private office with its own window!” Yay, no more cubicle!George climbed over the required HR training videos, slideshows, and a Himalayan mountain’s worth of paperwork, then headed to his new desk where a budget small-form factor PC with a single 17“ LCD monitor waited for him. ”Yeah, that’s real fabulous," he thought to himself. But perhaps it was just a placeholder system, quickly dug up from elsewhere in the building, to get him started while they ordered a proper developer-grade PC.It booted up and George realized he didn’t know his account credentials, so he wandered on down to the IT office to get set up.The IT Office, from the outside, appeared to be a large corner office, but inside it was cold and dark and of uncertain size, with the windows covered by blackout curtains and hidden oscillating fans blasting a chilly breeze through the office. All the room’s light coming from a single small table lamp situated at the sole occupant’s desk. Piles of unsorted equipment and cabling were scattered across the floor, barely visible in the poor lighting, a veritable obstacle course for any visitors with poor eyesight or agility. In contrast to the rest of the room, the desk itself was absolutely spotless, neatly holding the lamp, a keyboard and mouse, and one nice 40" display–nothing else. Not even a telephone. An empty office chair sat in front.As he entered the blackness, George could hear a rapid-fire chorus of clicking sounds–the kind that usually meant your hard drive had kicked the bucket–clustered around one floor-based pile of machinery which was only visible due to the incessant flashing of LEDs it possessed–LEDs which blinked in perfect time to the various patterns of clicks emanating from the area.George coughed to make his presence known, and the IT guy appeared near the desk with such silence that George wondered if he had materialized like a ghost. Due to the placement of their sole source of light, George could not even make out his features.“Hi, I’m George,” he introduced himself, extending a hand the man did not accept. “I just started here and I need an account.”The IT worker grunted slightly. He proceeded straight to one formless pile of equipment and sat down cross-legged next to it, right on the floor, moving so silently that George almost wondered if he had only imagined it. He made some barely-discernible motions in the dark, and a moment later a previously-hidden LCD monitor flickered to life, bringing new light into the room which allowed George to perceive that the monitor was precariously situated upon a pile of about five budget PC towers from at least a decade ago, heaped up like a deranged game of Jenga, the entire fixture surrounded by dark, snakelike cables of various types whiched meandered to and fro throughout the room.The screen came to, and George watched in fascination as it presented a Windows Server 2000 login screen. He then realized in repugnance that this pile of equipment was the very same one radiating the sickly click of dying hard disks. Surely this was not the company’s domain controller!The IT guy entered his login information, and upon his hitting “Enter”, the violent ticking of hard disks became frantic. The screen froze for a long moment–at the time it seemed like minutes–before switching to the classic desktop environment of an operating system serving well beyond its prime. The shadowy IT guy fished a mouse from somewhere in the darkness, almost as if by magic, and balanced it upon his scrawney left knee so he could use it. He clicked on the “Start” button.Nothing visibly happened at first, but the frenzied jackhammer of “Clicks of Death” told George everything he needed to know about the company’s IT infrastructure. Many long moments later, the Start Menu itself appeared, slowly drawing line-by-line into the desktop space at a painfully-slow rate. It completed rendering and the brutal ticking sound diminished somewhat.The IT guy attempted to open up the user manager, but as he clicked on its entry, the screen abruptly flashed to the bluest shade of blue, overlaid by a page of cryptic white text. George’s jaw dropped in horror but the other man remained perfectly silent. He reached a hand into the darkness and expertly stabbed the server’s reset switch with such ease that George surmised this to be a common occurrence, common enough for him to have developed impeccable muscle memory for the task.The system reset, flashed through its power-on self test, presented a RAID option ROM full of warnings about disk failure (which the IT guy completely ignored), and sat at the Windows 2000 Server loading screen for an eternity as its hard disks struggled from within to escape by the combined force of a dozen demon-possessed jackhammers.“Um, maybe I’ll just come back later?” George offered.“NO!” The man nearly shouted his first utterance since George met him, his retort sudden and forceful enough for George to flinch.And so George waited quietly, half-frozen in place by fear, watching the ghostly form of the company’s IT guy as he struggled through two more Blue Screens of Death on the company’s primary server before successfully opening the user manager and creating a domain account for George. Then he flourished, somehow producing a completed sticky note as if from thin air, and presented it to George. “It is done. Now go.”George took the sticky note and left the IT office as quickly and quietly as he could, carefully stepping around nigh-invisible pyramids of computer equipment and treacherous bundles of cable, eager to put the experience behind him and never step foot into the IT office again.As he entered the light outside the office, he peeked at the note which was scrawled with his username and password. But as he returned to his own desk to try the new login credentials, he could not expunge from himself an intense sense of doom, a growing despair that he had left one hellhole and entered a new dimension of pain and WTF-ery… [Advertisement] Atalasoft’s imaging SDKs come with APIs & pre-built controls for web viewing, browser scanning, annotating, & OCR/barcode capture. Try it for 30 days with included support.
Error'd: Lenovo Uh-Oh (and more!)
"I get it that some apps need special permissions, but a GUID is the digital equivalent of 'just trust me - I know what I'm doing'," Kenneth M. writes."Sometimes, vendors paint their accessories with golden paint," writes Geoffk C., "On the other hand, if you're Lenovo, you might produce a mouse made of solid gold."
Just The Fax, Ma'am
Gus had been working at his new job for a month. Most of his tickets had been for front-end work, making it easier and more efficient to manage the various vendors that the company did business with. These were important flags like "company does not accept UPS deliveries" or "company does not accept paper POs". The flags had been previously set via an aging web-based UI that only worked in Internet Explorer 6, but now they were migrating one at a time into the shiny new HTML5 app. It was tiring work, but rewarding.Unfortunately, as is so often the case, Gus quickly became pigeonholed as "the flag guy". Whenever it came time in the project to add new flags, there was no question who'd get the ticket. Gus could think of nothing he looked forward to less than touching the Oracle-based backend to the product, but unfortunately, it was his burden to bear.Adding flags to the database involved going through a special Database Committee. This was separate from the usual change request process. The committee was formed from all 6 of the company's database experts, and they personally reviewed every change. Worse, they were stodgy as all get-out. Any small error would get the change thrown out and the requestor berated for "wasting my time", along with a good helping of grumbling about "kids these days" and "narcissistic millennials" to boot.Gus submitted his change request asking for a new field 2 weeks ahead of when it was slated to go live, just in case. Submissions were due by Monday and were discussed on Thursday, with the results posted first thing Friday morning on the bulletin board outside the breakroom. Gus filled in every field carefully, checking the whole thing twice—all but the title, which he'd written as "New Database Feild". On Tuesday, he realized his typo. He quietly edited the form, saved it, then crossed his fingers.Friday rolled around and his change wasn't on the list, neither accepted nor rejected. Chewing his lip, Gus pulled up the change system and skimmed for his change.It was marked auto-rejected."What did you do?" demanded Chuck, the senior developer who'd been mentoring him."I don't know!" Gus replied. "Do you think it was the typo? But I fixed it on Tuesday!"Chuck slapped his forehead with his palm. "You changed the form? Don't ever change the form after it's submitted! That's grounds for automatic rejection!""It's okay," Gus said weakly. "We still have another week."Chuck just looked at him, shaking his head as he walked away.Gus spent the rest of the day focusing on the tedious form. There were dozens of fields, each with vague instructions, many demanding long explanations. Gus wouldn't be at the meeting to explain his change; he had to convince the committee it was necessary through the form alone. Worse, when he submitted it, it routed through an approval process that required him to chase down no less than 6 individuals to fill out their parts of the form."Yes, it's the same one as last week. Just put the same thing you did then. No, sorry, I don't know why it was rejected," he lied. "Can you just sign?"Monday came and went without another auto-rejection. Gus checked compulsively every day at lunchtime, waiting for the other shoe to drop, but his request made it to Thursday without incident. Finally, Friday came, and he made the trek to the breakroom to check the list.His change had been rejected.He didn't know why. He didn't care why. The application needed to be up and running for the first of the month—the following Tuesday. There was no time to try again. Gus walked over to Chuck's cube, his mind whirling. "What do you know about data hiding?"Chuck's face fell. He rubbed his face with one hand. "Dammit, this is why I try to pull front-end tickets.""You gotta help me, dude. I'm dying here!""Okay, okay, let me think. I've heard about some guys slipping an extra so-called check-digit into integer fields. You have to mask it out before the code gets to it, but ..."Gus grimaced. "I'd never get all the spots, I barely know the app.""You're sure you can't push back on the deadline?""Yeah. Can't we find a field that's unused or something?" Gus begged.An hour and dozens of SELECT statements later, they did just that. The Fax field wasn't populated in the old system; not a single vendor had a fax number worth recording. The new system hadn't bothered porting it over at all. Gus and Chuck hooked the flag up to the existing field. No muss, no fuss, and no database review.[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: Trimming the Fat
There are certain developers who don’t understand types. Frustrated, they fall back on the one data-type they understand- strings. Dates are hard, so put them in strings. Numbers aren’t hard, but they often exist in text boxes, so make them strings. Booleans? Well, we’ve come this far- strings it is.Tyisha has the displeasure of working with one such developer, but with a twist- they didn’t really understand strings, either. Tyisha only supplied a small example:
Awful On Purpose
Studying his new work contract, Stewart felt like he'd found a golden ticket. After 2 long and tedious years in the local university's IT department, he was happy for any opportunity to escape that hellhole. TLA Technologies looked like the Garden of Eden by comparison. Instead of being the only person responsible for anything vaguely computer-related—from putting up websites to plugging in power strips—he'd now be working with a "dynamic team of programmers" in a "rapidly growing company tapping into the web development market". Instead of dealing with tools and languages forgotten by history itself, he'd be using "modern, cutting-edge solutions" under "agile and customer-oriented methodologies". And instead of reporting to a pointy-haired supervisor who couldn't tell a computer from a toaster, he'd be working directly under Dave.Dave was a large part of why Stewart decided to take the job. Like most small company owners, Dave had taken it upon himself to personally interview the new hire—but unlike many of them, he had enough technical skills to make the interview feel less like a trivia game show and more like a friendly talk between fellow programmers. When Stewart's answers had strayed off the beaten path, Dave had been eager to discuss the solutions instead of just dismissing them, and when Stewart had started asking about the inner workings of the company, it'd been difficult for him to stump Dave with even the most precise questions. He seemed to know what his company was doing and what the coders need to deal with. What more was there to ask for from a boss?Stewart quickly scribbled his signature on the contract and handed it back to Dave."Welcome aboard!" Dave stood and extended his hand to Stewart. "You'll start next Monday.""Thanks for the opportunity," Stewart replied.Dave smiled. "Hopefully you'll prove yourself out on the battlefield. If you pull that off, maybe you'll stick around for a while!"In hindsight, the statement should've tripped an alarm in Stewart's mind, but being overjoyed with the prospect of a real job, he dismissed it as yet another cheerful promise. He left firmly convinced that all that glittered in TLA Technologies was gold.While Dave hadn't exactly lied, there were a few things he'd neglected to bring up during the interview. For example, when talking about "cutting-edge solutions", he hadn't mentioned TLA Technologies was using all of them. No two applications used the same tech stack. Each used whatever was popular at the time, with languages and databases from completely different ecosystems blended together until they worked. Luckily, Stewart got off easy with an only somewhat bizarre combination of a Node.js service running against a SQL Server database.The reason lay in what Dave had meant by a "dynamic team of programmers". Out of almost 20 developers, only 2 or 3 had any seniority. The rest were interns and juniors who came and went before anyone even learned their names. There was hardly a week that wasn't marked by desks being emptied, only to be filled by new hires within days. Everyone brought their own favorite technology to the potluck—sometimes introducing it through legitimate channels, sometimes sneaking it into parts of the application that'd be deemed untouchable once the original developer left.There was exactly one person in the company with enough authority to rein the developers in. Unfortunately, Dave spent most of his hours at water cooler discussions, exchanging the latest IT gossip and encouraging the devs to explore new tools. Occasionally, he retired to his office to explain to one of the people he'd just been chatting up that they were "no longer a good fit for the company".Stewart restrained himself from asking questions for quite a while, until one day he saw an empty desk a little too close to his own."Hi, boss," he said, entering Dave's office. "Do you know where Rob is?""Who's Rob?" Dave asked in a dry, uncaring voice, barely looking up from his monitor."Um ... Rob the front-end developer? He was supposed to finish a feature by today, and—""Oh, that Rob. We had to let him go. He wasn't pulling his weight on the new project.""What do you mean? He's only been on that project for 2 weeks!" Stewart fought the urge to start shouting. "We'd just started introducing him to the codebase. Surely you don't expect—""Look, Stewart." Dave interrupted him again. "When we bring a new developer into a project, even an intern like Rob, the customer expects our performance to grow. They want results, and it's our job to deliver them. Unfortunately, with Rob, the entire team slowed down as soon as he started working. I'm sure you understand why it had to be done."Stewart understood perfectly. With a polite nod, he scooted back to his desk, thinking about an escape plan.The days kept passing, and Stewart was still gathering the courage to hand in his notice. In the meantime, he struggled to figure out the twisted logic of the service he was working with; one of the previous developers apparently figured that Unix timestamps made great database primary keys. This worked well in development and crashed hard in production. To "patch" it, at every insert, the application would sneak a blank record in between other requests to lock the row for itself. Once it reserved the row, it would then update it column by column—and with some tables having up to 40 columns, that meant 40 UPDATE queries per record.It was a bizarre, Goldbergian design. Stewart decided to ask Dave to allow him to refactor it into something sane."Yeah, that is terrible," Dave agreed. "Why wouldn't they just use an identity field?""Exactly!" Stewart felt like he and Dave were finally on the same page. "It shouldn't take too long to fix, and it would certainly be much better for performance and development.""But the current code works, doesn't it?""Um ... for now it does, yes. But it's already a performance killer, and once more people start using the service, it's going to be much worse.""They aren't using it now," Dave said. "And the client hasn't complained. As a developer, I understand where you're coming from—but as a company owner, I can't agree to spending time on something that delivers no value."Stewart's eyes widened in shock. It was a catastrophe waiting to happen. At the current rate, the performance would get unbearable in a matter of months. And Dave was just dismissing it like it was nothing? What had happened to the "customer-oriented" company?"Besides, this is an opportunity to cash in on our support contract," Dave answered, as if reading Stewart's mind. "That's how it works in this business. If it ain't broke, don't fix it—unless the customer's paying.""I see," Stewart muttered. As he left Dave's office, he decided to take the advice to heart. Not only was he not going to fix the application, but more importantly, he also wasn't going to spend any more time trying to fix TLA Technologies. He walked towards his desk, unlocked one of the drawers, and pulled out a piece of paper that'd been waiting there for far too long. [Advertisement] Scale your release pipelines, creating secure, reliable, reusable deployments with one click. Download and learn more today!
CodeSOD: Indentured
Speaking with developers, I’m always surprised to find a surprising percentage are surprised and baffled by the “Fluent API”. This object-oriented convention is based on the Builder Pattern, and involves call chaining to construct a configured object. So, for example, if you needed to configure a SystemHandler object to have a series of LinkHandler objects, you might have something like this:
Classic WTF: Illicit Process Improvement
In celebration of Black Friday, also known as "Retail Hellscape", let's look at a retail-oriented classic WTF, which originally ran way back in 2007. We'll resume our regularly scheduled WTFs next week.--RemyChristian R. was in trouble. Despite his experience across hardware and software, desktops and server clusters, thumb drives and SANs, he hadn't found any freelance work in weeks. It was clear that he'd have to figure something out to pay the bills.In August, Christian applied at Drab's PCs, a large retail chain focused on computer hardware and software. He'd shopped there for years and had an impressive level of knowledge about their products, so he accepted a position in Technical Sales.After a few months of working at Drab's PCs, Christian grew tired of one of his tasks — manually keying in orders from the online store. The online store worked by emailing orders to individual branches across the country, which were then printed, given to the branch manager, and then distributed to employees. The employees would then key in each order, line by line, item by item.Entering orders was more time consuming than it had to be. Since each system had a barcode scanner, it didn't make sense to totally retype UPC codes and serial numbers. Having worked with PHP's image manipulation functions, Christian decided to take on a hobby project — a quicker interface to enter online orders.He bought himself a barcode scanner and got to work. After a few evenings of coding, he had a working prototype. It would take in an order email, convert UPCs, serial numbers, quantities, and prices to barcodes. The barcodes were aligned on the page such that the barcode scanner could simply be dragged from the top of the page to the bottom, generating a complete, accurate order.For a few weeks, Christian would use his application rather than typing orders in manually. Even after verifying that the order was complete and correct, he would still finish well before his coworkers. Gradually, word spread about his application, so he shared it with a few friends at his store.His circle of users were happy, but when word of Christian's application bubbled up to management, Christian was called into his boss's office. "Let's have a competition," his boss, Warren, began. "I'll have Bill enter an order against your program," he said. "He's the fastest at this, and I want to be sure that we're doing this the most efficient way we can."Christian and Bill started, and before Bill had fully keyed in the first item, Christian had processed an entire order. Happy with the results, Warren thanked Christian for his work and told him he'd talk to the branch manager about it.A few days later, Christian's branch manager, Larry, called him into his office. "I saw the order entry program you made," he began. "You're lucky I haven't fired you.""I... I'm sorry?" Christian was dumbstruck. "Did it mess up an order or something?""No. I just don't appreciate your interfering with the deployment of the new system." The "new system" had been coming soon since the day Christian was hired. Christian had never intended to interfere with plans made by corporate, he just wanted to make his life a little easier. He tried to defend himself, but Larry was unconvinced. His application had put him at odds with corporate.A year passed, the following winter came, and Christian was due for a performance review. After his boss, Warren, and the branch manager, Larry, had finished Christian's performance review sheet, he was called into Larry's office to review. Christian took a deep breath before walking in.Before Christian could even sit down, his review began. "You're not smiling enough," Larry began."You have the best feedback out of all of our staff, though." Warren was happy. "Customers love yo-""But they think you're cold and unfriendly. Why don't you smile more?" Larry interrupted."Really, though, your technical knowledge is great," Warren said. "And I've had more customers thank me for your hel-""I see here that you were almost ten minutes late on June 8th. You missed a team-building exercise!" Larry scowled and leaned forward. "Why don't you tell me about that day.""Well, there was a car accident which caused a delay," Christian began, "and I don't really have a good direct route in anyway. Still, I was still at my desk, ready to serve customers when the doors opened, so I don't think it was that big a deal...""Yes, yes. Well, let's cut to the chase. We've decided you can keep your job," said Larry with an insulting smile. "Sound good?"Christian was speechless. He looked to Warren for help, but Warren was timidly staring at the ground. He stumbled while mentioning a few improvements he'd made to the store, some thankful customers he'd served, but those comments were barely acknowledged."I'm not being considered for a raise then?" Christian finally asked."No, but you can keep your job," Larry reiterated."Will I be eligible for a raise next year?""No.""The year after that?""Y... maybe.""So, to get this straight, I have to work three years on my best behavior, be essentially the most incredible employee the store has ever had, and then, maybe I'll get a raise?""Well, if you put it like that...""Understood." Christian sighed and went back out to his desk. Two months later, he found a new position and has been there for several years now. He found out that corners were being cut across the board not only because the store didn't have a great year, but a new, expensive corporate office had been built that year.And that new system is still coming soon, but it's seriously right around the corner. [Advertisement] Application Release Automation – build complex release pipelines all managed from one central dashboard, accessibility for the whole team. Download and learn more today!
CodeSOD: Classic WTF: Injection Proof'd
It's Thanksgiving, in the US. Be thankful you're not supporting this block of code. --Remy
Error'd: Actually, My Father was a Folding Chair
Unpythonic
CodeSOD: The Rule of Ten
Florian’s office has a “rule of ten”. Well, they don’t, but one of Florian’s co-workers seems to think so. This co-worker has lots of thoughts. For example, they wrote this block, which is supposed to replace certain characters with some other characters.
Error'd: Does Anyone Here Speak CSS?
"If you ask me, it's not just English speakers that GSMArena is in need of," wrote Aankhen.
The 10x Developer
“You’re going to learn quite a bit from Burt,” Burt said. “He’s one of the best.”Davide blinked. He wondered if his new boss spoke about himself in the third person as a matter of course. Cautiously, he said, “Well… I hope so?”“Burt’s been with us since the beginning,” Burt continued. “Nobody but nobody knows our systems and our environment better than he does. He’s one of those… whatchacallits…” Burt glanced around his desk, and found what he was looking for- a glossy trade-mag with a cover story about the most productive developers. “A Ten-X developer. We’re really lucky to have him, and you’re really lucky to work with him.”Burt was not speaking in the third person. Burt, the CTO of the company, was a huge fan of Burt, the lead developer at the company. When Davide was hired on, CTO-Burt spent a lot of time praising the genius of Dev-Burt. Once David started working, he didn’t see CTO-Burt very much, but Dev-Burt also was eager to talk about what a genius he was.“Not just anybody can manage a system with 100KLOC, mostly by themselves,” Dev-Burt said. “But stick with me, and maybe you’ll learn.”Dev-Burt’s genius was questionable. Five minutes skimming the code-base made it clear that Dev-Burt had the coding conventions of a drunken lemur. The only thing that made the code even slightly readable was that most of it was in Python, and thus had to be indented logically. That was the only logical thing about it. Some variables were named in camelCase, others in snake_case. Half of them were just alwayslowercase. Function names were generally more consistent, only because there were fewer of them: Dev-Burt was the kind of developer that just loved to write 5,000 line functions. There were plenty of global variables, plenty of spaghettified code, and plenty “god” objects that mashed together thirty unrelated behaviors into one mess that behaved differently depending on which specific flags you set.Dev-Burt was too busy being a 10x developer to give Davide any guidance about what he was supposed to do. The only coding conventions appeared to be “Dev-Burt does whatever Dev-Burt wants.” From time to time, Davide would pick up tickets as they came through, tracking down and patching bugs, but mostly he tried to find opportunities to refactor the code and add some unit tests.This radical behavior lead to a tense meeting with the Burts.“Burt tells me you’re causing problems,” CTO-Burt said.“He’s making a mess out of my code,” Dev-Burt complained. “He’s making it more complicated!”“I was just refactoring it so-”“There he goes,” Dev-Burt said, throwing a hand in the air, “using his made up buzzwords. Look, we’ve got product to ship, and your refractioning isn’t getting us anywhere. I wouldn’t mind so much, but it’s eating into my own time, and making it harder for me to get work done!”“That’s bad,” CTO-Burt chimed in. “Because Burt’s a Ten-X developer. His time’s ten more times as valuable as yours.”At least, after the meeting, Davide had clear rules to follow: Dev-Burt does whatever he wants, Davide does whatever Dev-Burt tells him to, and Davide was not to touch any code unless it was to deal with a ticket assigned to him by CTO-Burt.This gave Davide a lot of downtime, during which he could watch the codebase grow. It was true, Dev-Burt was a 10x developer, in the sense that he could write ten times as much code as necessary and he’d often write the same code ten times, in different places in the application.One day, while wondering if this made Dev-Burt the first 100x developer, Davide received a new ticket. One of the automated jobs had failed, dumping a stack trace to the log, and it kept failing every hour. It didn’t seem to be having any other effects, but CTO-Burt wanted it fixed.Davide assumed there was an un-handled error, and dug through the stack trace to find the offending code. He was half right. Once he cut away the bulk of the logic, the basic structure of the method was this:
CodeSOD: Coldly Fused
In 1989, a pair of physicists claimed to have achieved the fusion of hydrogen at room temperatures. This came as quite a shock to other physicists, since fusion was only known to happen inside of stars. Within a few months, their claims were roundly rejected. Cold fusion became synonymous with junk science.Fast forward to 1995. when a small company wanted to make its own set of generous claims about its web application framework. Allaire, Inc (eventually bought out by Macromedia, which itself was eaten by Adobe), claimed that its Cold Fusion could solve all your web development problems. All of your web development challenges could be solved through the judicious application of CFML.Fast forward to today, where I’m surprised to learn that ColdFusion is still in active development. Brian recently had the pleasure of attempting to install it. First, he was annoyed at just the install size- 1.2GB for a web runtime and its assorted libraries. Then… the install failed. Brian poked around in the installer and found the following shell script:
The Logic Barrier
Brad was brought in as a new hire to work on improvements for a big-name ERP system. His supposed role would be that of the "input guy" for a new I/O module where engineers would enter some numbers, they would be crunched, and it would output a wireframe design of what they needed to build. While he got started, the development manager Cindy assured him they'd have an "output guy" soon enough.A month passed while Brad was making good progress. One Monday, Cindy walked up to his desk with a tall, dark-haired gentleman in tow. "Brad, this is Dmitry, your 'output guy'.""Hello Bard. I am Dmitry. Please to see you," he introduced himself with a firm handshake and large grin.After Dmitry got settled in, Cindy came back to Brad and told him in a hushed tone, "He just got here from Russia. He might be a little hard to understand, but boy can he code! You might need to give him a little guidance since your part of the application comes first, but I'm sure it will work out great!"So began several arduous weeks of Brad working on his input interface about 15 minutes a day, while assisting Dmitry the rest of the time. They got far enough to prepare an end-to-end demo for Cindy. When she arrived, Brad put in the specifications for some plumbing parts he found online. They were passed to Dmitry's code and out came what looked like a reject from Rorschach's inkblot test."Oh no!" Dmitry cried. "I think I forget to check in part of code. Need a little more time," he requested with a grin and a nod."Brad!" Cindy shouted, crossing her arms. "You obviously aren't getting through to Dmitry. Before the next end-to-end test, I want you to test your own components first, then cross-test each other's. I expect better results next time!"Brad ran through his own code exhaustively while Dmitry supposedly did the same. "Dmitry, I'm ready to exchange code when you are. Everything seems ok on my end.""Oh yes! My code is good, yes. Add a few more DLL, more logging. Great now," Dmitry assured him.Brad attempted to test Dmitry's code but couldn't even get it to run. He found several initial run blocks, proving Dmitry never even once ran his code because surely he would have noticed the myriad uninitialized collections and NullReferenceExceptions.Brad explained the situation and offered assistance but Dmitry assured him "No, no. You sit, I code and fix it up." An hour passed before Brad got an email from Dmitry with a .zip attachment that said "Deploy new DLL. Code working." Brad did just that only to find the code NOT working.With day turning to night on the Thursday before their Friday demo, Brad decided it would be more efficient to dig in and fix Dmitry's code himself. "Dmitry, just head home. I have some troubleshooting to do on my code," he lied. "I'll get it fixed up before the demo.""Maybe you need the coding practice!" Dmitry grinned while putting on his jacket. "Goodest luck, tomorrow bring great success."Brad committed the changes to Dmitry's code around midnight in what amounted to a complete re-write. Weary, he went home relieved that Cindy would be off his back for a while after the demo. That would give him time to figure out what to do about Dmitry.The following afternoon, the demo to Cindy went off without a hitch now that it had been purged of most of Dmitry's code. Cindy was pleased with the results, "great job gentlemen! How about we go out to the pub to celebrate! I'm buying the first round."Brad would have preferred to go home to collapse, but he couldn't pass up a free drink. The three of them engaged in awkward small talk over a round of beers. Dmitry offered to buy the next round when he switched to vodka. Cindy left after Round 2, leaving Brad and Dmitry who both seemed to have an unquenchable thirst.Brad was growing to like Dmitry when he ordered yet another round, putting them on the verge of not being able to stand. Dmitry leaned over to him, bleary eyed and said, "let me tell you a little secret." In perfectly clear English but still with a heavy Russian accent, he shared, "I apologize. I do the broken English thing so people don't expect a lot out of me. It's really the whole logic part of the job that I struggle with. I have a hard time understanding computers. Sorry you had to spend so much time fixing my code."The stunning revelation caused Brad to temporarily snap out of his stupor. When Dmitry went to the bathroom, he pulled out his phone to text Cindy, "We need to talk about Dmitry on Monday. Don't call me tomorrow, the phone ringing will hurt my head." [Advertisement] Incrementally adopt DevOps best practices with BuildMaster, ProGet and Otter, creating a robust, secure, scalable, and reliable DevOps toolchain.
CodeSOD: Just In Case
Brandon’s company had a lot of work to do, and not enough staff to do it, so they hired on some freelancers. They were careful about it, and felt like they’d hired some good people. One developer, in particular, was the kind of developer who not only understands the low-level Windows API, but actually knows how to use some of the undocumented corners of it to get things done.Most of the module was pretty good, but when Brandon double checked on the method for escaping disallowed characters from a URL, he found some problems.The function went character by character through the string, which was bad enough, but when it wanted to know if a certain character needed to be escaped or not, it called this function:
Error'd: Let's Eat
"Apparently, only a small part of my dinner qualifies as food," writes Alex F.
Exceptional Handling
Enterprise Resource Planning software, or ERP for short, is crucial to the operation of many large businesses. Several popular ERP systems have plugin-friendly architecture, the better to sell upgrades their customers will never want or use. This software is primarily aimed at businesses with too many complex process flows to manage by hand—making it the perfect domain for a small, lean startup with 3 developers and 1 customer.Ethan and Roland were brand-new developers, fresh out of college and ready to take on the world. Patrick, a consultant, was more experienced, though still fairly early in his career. They worked in C# with the Visual Studio ecosystem, and their boss had bestowed just one instruction as to how their culture should be formed:"Picture a scale from 1 to 10, with 1 being fast and 10 being scalability and code quality and all that crap. I want you to aim for a 2."Visual Studio is a great tool for beginning developers who need to work fast. It makes scaffolding the code simple and efficient, and allows for a drag-and-drop visual design that lets you rapidly prototype your screens. Couple that with great intellisense, and the team was confident they could deliver their addon as promised.That said, Visual Studio is also a complex piece of software, with many of its best features hidden inside a labyrinthine menu system and/or optional settings deep in a configuration file. It works better if you have time to learn how to use it. Unfortunately, our ERP team did not have that kind of time, and they missed a few key features. For example, out of the box, Visual Studio won't step into a catch block while debugging. You can debug catch blocks, but you have to explicitly set a breakpoint in them or they will be skipped entirely. There's an option to turn this behavior off, but it's hidden deep in the menus.Ethan and Roland developed a workaround for this behavior that let them continue working: they would comment out catch blocks surrounding code they were actively debugging, then restore the commented-out code afterward. But this took time and effort, and often multiple cuss-filled executions as they realized the exception was handled at a higher or lower level than they'd originally anticipated and they had to comment out more code. Finally, Patrick came up with a more creative solution: pre-emptively comment out all try-catch blocks in the entire solution, and stop adding more."There's no time for exception handling," he scoffed. "We have to move fast or we won't hit our street date."Ethan was concerned by this solution. He'd already caught himself forgetting to un-comment catch blocks using their old strategy. Wasn't this infinitely more risky? And how would they know their catch blocks were written correctly? What about testing the error messages they were meant to display to the users? Still, he was brand new, and Patrick had industry experience, so he was overruled.The weeks wore on, and development moved at blazing speed. The developers did their own unit tests, and from time to time, their BA would perform manual tests of the addon installed in the ERP system. It mostly crashed, but it was early yet. There was time to figure it out. Still, blazing isn't quite lightspeed, and the BA kept finding more and more crucial functionality that would be required if anyone was going to be interested in purchasing the thing. The general feeling of the project team matched the immortal words of Sonic the Hedgehog: "We're not going to make it. Let's speed up!"The team took on more developers in an effort to increase overall velocity. One of these was Alex, a contractor with 30 years of experience handling IT projects. Alex rapidly emerged as the clear leader of the entire team; his age and experience dethroned even Patrick. He spent increasing amounts of time sequestered with the boss, talking through everything from planned features to plugin architecture to the speed of development, which the boss felt was responsible for their missed milestones. Not because the code quality was crappy and therefore more time was spent fixing bugs, but because developers "weren't coding fast enough."The codebase had grown from a few hundred lines to several thousand. Ethan had found the magic toggle for Visual Studio that made it step into catch blocks, much to his relief. He reported this to the boss, and the ban on exception handling was (begrudgingly) lifted. Ethan adjusted rapidly, but many of the other developers still blamed exception handling for the slowness of coding. Often the addon would crash due to an incorrect cast or bad index. However, handling exceptions was seen as wasted time, so many developers refused to do it.Upon overhearing the boss and Alex discussing the matter, Ethan threw in his two cents. "We're nearing release. We should really start adding exception handling to all new code. Then we should do a final round of testing to make sure nothing breaks."This didn't go over well with the boss. The solution was simple to him. "Just don't use any exception handling. Remove all of it. Then we won't have to test anything extra, and we might even make our deadline."Ethan, after retrieving his jaw from the floor, protested violently. "Who's gonna pay for a system that crashes the moment you look at it wrong? What about data integrity? If bad data is persisted to the database, it'll fill up with garbage—and then the application will throw even more exceptions!""I know it's not ideal," said the boss, "but there's no time. Remember the scale: we need to be at a 2, and you're at like a 6 right now. This is industry standard stuff. Trust me on this, okay?"Time marched on. The company doubled in size, adding more developers who were forbidden from using exception handling. They moved even faster now, approaching the final ship date—well, the new final ship date, anyway.One day, while debugging, Ethan noticed that the addon didn't crash anymore, but did log an error to the console. "Wait, what? Where was that handled?"Concerned, he dug through the code. Most of his exception handling had been removed or commented out; he couldn't find a single catch block in the whole module he was working on. Finally, he found it: at the very top level, someone had put a try-catch block around the entry point to swallow any exceptions that were thrown.Ethan asked Alex about it the next time he caught him in the hallway."Yeah, we can't have the addon crashing all the time, you know?" Alex shrugged.Another junior developer poked his head out of a nearby cubicle. "It turns out, in C#, if you have an exception, the entire application crashes! Crazy, right? I found that out last week, and I told Alex about it, so we decided to implement exception handling."Ethan had no words at first. He just cradled his forehead in the palm of his hand. Finally, he tried one last time to explain. "Look. Exception handling is a good idea. But this is going to swallow all the errors, so debugging will be impossible. At the very least, let's put a catch block around each module so we know which one failed. And stop removing my catch blocks!"Alex shook his head. "You just have to do it right. All of you," he added, raising his voice so the others could hear. "If you just code it right from the start, there won't be exceptions, and handling them won't be necessary!"Ethan learned a valuable lesson that day: why exactly it was that startup developers tended to congregate in bars and debate the merits of various fine liquors online. It wasn't that people who liked alcohol were drawn to software development. Working at places like this drove developers to drink. [Advertisement] Universal Package Manager - ProGet easily integrates with your favorite Continuous Integration and Build Tools, acting as the central hub to all your essential components. Learn more today!
CodeSOD: Repeat Delete
Once upon a time, a client contacted Trick R. and asked him to figure out why files were disappearing from their website.The seemingly innocent task proved to be a swan-dive into a sewer of bad PHP, unsanitized user input, and plain-text passwords stored in the database, among other vulnerabilities. However, the following conditional took the cake for awfulness. What better way to ensure a record is really gone than by running the DELETE query a bunch of times?
A SNOBOL's Chance
We’ve all inherited legacy systems. You know the sort; 20 years old, more than 50,000 lines of code, poorly designed - even for its time, completely undocumented externally and useless code comments within, mangled beyond recognition due to countless developers making myriad ad-hoc changes upon changes and so-on. Now imagine such a system written in a tool that’s been around for nearly half a century, but rarely used for the intended purpose of the application.Reg worked for a firm that built space-rocket related applications; specifically an Ada compiler, written in SNOBOL, for a 15+ years obsolete legacy processor used in the rocket. The system itself consisted of more than 100 SPITBOL (a speedier compiler of SNOBOL) programs, most of which were written by one guy nearly four decades ago, Barry. Barry was a former sixties hippie-turned-coder. Though long since retired, he had been called back to active duty to try and help decipher what this thing does.The code is full of comments explaining what each block does, but not why. Nor were the comments up to date with what the code actually did, which was one set of “bugs”, in addition to the more normal set of errors. Of course, in those days, nobody wrote unit tests (was it even possible to write test suites for SNOBOL?) Some of the more interesting phenomena included mangled memory addresses, incorrect hex/decimal conversions, offsets disappearing, seemingly random mangling/unmangling/remangling of variable names, etc.Reg’s ongoing project was to replace this mess with a shiny new Ada compiler written in Python.Along the way, Reg had to deal with all the control flow of SNOBOL (e.g.: goto’s), on-the-fly execution of strings containing arbitrary SNOBOL code, the immediate-value-assignment operators (‘.’ and ‘$’) and pattern matching that would reduce a regex-wizard to a quivering mass of Jello.Even Barry, the tie-dyed, retired, hippie could no longer decipher what the internals were doing. Maybe he’d just fried too many neurons. Reg couldn’t get any further- maybe he just wasn’t smoking enough marijuana to understand what the hippie had done. Reg decided to simply try to replicate the output of the legacy system. This was accomplished by running both systems on the same input and doing diffs.This project started long before Reg joined the firm, and will probably be going strong long after he’s gone.Reg got the number of diffs on the output down to less than 1,000. That might not sound great, but almost all of them were caused by bugs in the legacy code.Now his toughest job begins: explaining to management why success must be defined as about 1,000 differences in the output between the legacy and replacement systems, and, more importantly, determining whether correcting the output of the previous systems will cause the rocket to act in an undesirable manner. Like exploding.[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: A Type of Test
Unit tests are a wonderful tool for proving that your code works. Ideally, when you’re using other code, like say, the .NET Framework, you don’t write tests that test the framework itself. After all, didn’t Microsoft already do that?David T’s co-worker laughs at your naïveté. Why would you trust Microsoft? You need to make sure the framework works as advertised. Which is why their unit tests are mostly made up of code like this:
Error'd: "X" Marks the Spot
Dan writes, "This happened when selecting 'see more' under my (Your) recommendations. Maybe there's buried treasure somewhere?"
The World Tree
When Nate was wrapping up his senior year of college, he hunted around for a job that would hire an undergrad on flexible hours. He knew that the kinds of companies that tended to hire on those terms could often have… creative practices, but college wasn’t about to pay for itself.He found a small shop that needed an extra hand. Extremely small- there was only one other developer, Gordon. Nate was prepared to enter a tiny shop with no real practices or procedures, because with only one developer, you don’t expect a lot of rules and bureaucracy.Gordon was only one person, but he was able to create enough contrived, arcane, and downright mysterious bureaucratic policies and procedures for fifty developers. Reading the style-guide was closer to reading a novel, but not a good novel where there was a clear point and narrative thread, but something meandering and pointless, like a Douglas Adams book.Gordon wasn’t just opinionated about style. He also had Opinions™ on the proper use of source control. “Branches,” Gordon explained, “are absolutely vital for separating units of work.”Gordon’s explanation came after Nate was stunned by the sheer number of branches- there were hundreds of branches in the repository. “Look,” Gordon said, “you don’t have to be intimidated by this. We can start you out, just do this small change in the main branch, then I’ll show you how to release it.”Nate dutifully checked out master, made the change, and committed it. He sent Gordon a pull request.“You used the wrong branch. Back out your change, and put it in the main one.”“Which branch is the main one? It’s not master?”“It used to be, but we don’t really use master anymore. Use master_4513.”As it turned out, the “main branch” was usually whichever branch Gordon touched last. There were five or six different branches that could be the “main” branch at any given time. Maybe seven- it was very hard for Nate to be certain.Nate made the changes in master_4513, but that was only the start of the nightmare. Now, those changes had to be merged into the correct branch for deployment. “This is pretty complex, do you want me to walk you through it?” Gordon asked.Nate said yes, and so Gordon sat down next to him, and started explaining each step that Nate needed to perform. These “explanations” started with Gordon pressing his fingers against Nate’s monitor and saying, “Click here.” “No, fire up the GUI, not the CLI.” “Select this branch.” The instructional process was recorded as a smear of fingerprints on Nate’s screen.Changes merged outward from the main branch (whatever “main” happened to be that day). Instead of merging back towards a known-good trunk of code, changes were made to the trunk, and then percolated outward, according to Gordon’s own twisted logic. “You see,” he explained, “we’ve gotta maintain, like, 15 different versions, and some of them depend on a different version of our framework lib. This main version builds against version 1.2 of the framework.”“But… isn’t your framework up to version 4.5? Like… for years now?”“Yeah, but this change only goes out to the 2.0 users, so you need to merge from main to master_51, then to frameworkupgradeA1, then to perky_peregrine. You’ll need to resolve conflicts.”Nate ground his teeth hard enough to make diamonds between them, and fought his way through the merge conflicts. A few hours later, Nate’s one line change was merged into a releasable version, but Nate had no idea how that change would migrate to any other version, if it ever did.Nate’s next assignment was to make a change to the same version, and since it was a larger change, he made a feature branch off of perky_peregrine, do the changes there, then merge right back into perky_peregrine after the work was done. Then he could propagate the changes back to the current “main” branch, asdfg. This resulted in an angry visit from Gordon.“Are you trying to mess this up?” Gordon demanded. “There is a system. There are policies! Did you even read the development guide I gave you? Feature branches are fine, but they have to come off the main branch, not one of the dependent branches!”Nate had tried valiantly to read it, but failed. “I was just going to do the work, merge into perky_peregrine, and then delete the branch, why does it matter?”“Merge back?” Gordon shrieked. “DELETE the BRANCH? Branches don’t merge backwards, only outwards. Like a tree. Each feature branch is supposed to be an entirely new line of development. Have you even used source control?”Something snapped in the back of Nate’s brain, because for a brief, terrifying moment, that almost made sense. Nate had been puzzling over the bizarre state of their source control repository, and those words from Gordon put understanding it within tantalizing reach. If he asked a few more questions, he might just see the method to this madness…Nate chose the wiser path. He smiled, he nodded, he complied with Gordon’s policies, and moved on to the next feature, weeks after cutting through the shrubbery that was Gordon’s branching system.The next feature was to make a change that only impacted users of the latest version of the base framework. The current “main” branch was back on version 2.3, so Nate needed to start by making a branch from there. Then he had to bring it up to version 4.0, then convert a few of the datafiles into a new format, then finish the upgrade to 4.5. This was about two weeks of hair pulling frustration. Then he could make his changes. He spent that week asking serious questions about the career path he was on. Finally, he could merge his changes into the actual 4.5 release branch, but never back into any master branch.This resulted in tens of thousands of merge conflicts. The next few weeks were spent cutting through them, and by the end of that time, Nate discovered the semester was nearly over. He was about to graduate. He went to Lindsey, the co-owner of the small company, and handed in his resignation.“We’ve been really impressed by your work,” she said. “You could stay on after college, if you like.”Her tone was even, perhaps even a little indifferent, but there was a plea in her eyes. Nate vaguely recalled hearing that Gordon was a friend of Reggie, the other co-owner. Nate saw a hint that Lindsay knew what Gordon was doing to their software product. Maybe she thought Nate could be her ally in fixing it.Or maybe Nate was reading too much into it. Discretion was the better part of valor. “I’m sorry, I just don’t think I’m the right fit for this team,” he said. They made the polite noises, she promised him a recommendation letter, they connected on LinkedIn, and Nate went off to find a source tree that didn’t look like a tangled briar.A few months after Nate settled into his new job, he snooped on Gordon’s LinkedIn profile- he was unemployed. A message to Lindsay confirmed that she’d fired him over his inability to deliver new features. The last anyone had heard, Gordon had retired to a cabin in the woods, where he could be alone with many branches that never merged back into their trunks.Editors Note: We meant no harm in teasing Douglas Adams, but your reaction was much more interesting than it would have been to another tired Twilight joke.
CodeSOD: Dollar Dollar Dollar Dollar Underscore
An Anonymous source sends us some Java code they found in source control, with really special variable naming conventions. I can only assume this came from a plucky startup hoping to attract venture capital.
No Account for You
Ed wasn’t excited about his job. He worked for a large automotive manufacturer. This is the kind of industry that might invest heavily into robots and research and development, but when it comes to managing their supply chain and accounts receivable, their IT infrastructure was frozen in amber circa 1974.The pay was fine, but the work was frustrating. Things like “Code reviews” and “refactoring” were viewed as “wastes of time” or “developers playing with toys”. Unit tests were a luxury for “lazy” developers- good developers should just be writing code that works. If the work you’re doing isn’t directly involved in getting cars built and shipped, you shouldn’t be doing it.Ed was looking to get out of the company, and while he kept sending out resumes, he found more excuses to get away from his desk by taking smoke breaks with Mitchell. Mitchell was a lifer- he joined the company back when pensions were a thing, and was close enough to retirement that he just needed to keep his head down and stay the course to check out with a nice nest-egg. “But you,” he’d tell Ed, “you’ve gotta get out of here. You’re young. You shouldn’t be wasting your time here.”After one of those smoke breaks, Ed returned to his desk to see Pilar waiting for him. Pilar was their summer intern, a junior in college. She mostly handled “manual reporting”, which was a euphemism for “we don’t actually have a reporting system for this data set, so we have an intern run SQL queries against production and then copy/paste the results into a spreadsheet.” Yes, there were still manual reports because none of the SBUs wanted to pay to automate them.“I’ve got a new report,” she said, “and it’s on something called SCORDBE? You wouldn’t know how I get access, would you?”Ed didn’t know. At best, he might have seen the acronym someplace on a PowerPoint during a quarterly meeting once. “No, but has anyone shown you the Internal Apps Sheet?” He was referencing a spreadsheet used to track support contacts for different applications. He CTRL+F-ed to the entry for SCORDBE. “Oh, no…”The SCORDBE database was administered by Yev “Ticket-Nazi” Kassem. He automatically closed any tickets for changing the database- even for production releases. Any ticket requesting access to the database, for any reason, received a simple reply: “NO ACCOUNT FOR YOU.” He used IP whitelists to prevent connections from unapproved devices. While it probably was good for security, that was an afterthought. Yev had a small bit of power, and he wanted to make sure that he held onto it.Still, that was just the database side. There was an application on top of that database. He scrolled across the spreadsheet, past the cloumns for “Approving Manager”, “SBU Contact”, “SBU Backup Contact”, “SBU Backup Bakcup Contact” and found “IT Development Contact”. It was Mitchell.“I don’t think you’ll get very far with the database,” Ed said. “But maybe Mitchell can help?”Pilar went off to visit Mitchell, and Ed got back to his regular work. A half hour later, Mitchell CCed him on an email to Pilar. “I’ve got a solution. Just visit this URL and it’ll run your query. And you can change the id=… part at the end to do it for other part numbers.”Ed didn’t think much about it until his next smoke break. “So,” he said, “how’d you get past the Ticket-Nazi?”Mitchell laughed. “I didn’t.” He paused and lit his cigarette, taking a few drags before explaining. “SCORDBE is about 35,000 lines of Perl written back in the 90s. Nobody ever wants to touch this code, and nobody really understands what it does. I figured there had to be some poorly escaped queries, so I just grepped until I found one. Now we can run ad-hoc queries as needed.”Ed left the company a short time later. Mitchell, and his injection-based reporting solution, however, are still there. [Advertisement] BuildMaster integrates with an ever-growing list of tools to automate and facilitate everything from continuous integration to database change scripts to production deployments. Interested? Learn more about BuildMaster!
CodeSOD: The Wisdom of the Ancients
As Halloween descends upon us, mysterious emails start reaching our inbox. These plaintive missives are but the screams of the damned, encoded and sent over SMTP.For example, someone known to us only as DBA Guy sent an email with this subject: “Silver bullet SQL scalar function built by the Ancient Ones”.These ancient ones obviously did not come from the Euclidian plane we know so well, but obviously from a twisted, higher dimensional space where there exist no right angles.The code itself, is simple:
Error'd: Going Fast
"This building is sinking so fast that it lost 4 floors between the headline and the body," writes Hans.
Deep Fried Offshore
Stephen worked for an Initech that sold specialized hardware: high-performance, high-throughput systems for complex data processing tasks in the enterprise world, sold at exorbitant enterprise prices. Once deployed, these systems were configured via a management app that exposed an HTTP interface, just like any consumer-grade router or Wi-Fi access point that is configurable through a website (e.g. 192.168.0.1).Stephen worked with a diverse team of American engineers who were finishing up the management application for a new model. The product was basically done but needed a little bit of testing and polish before the official release. They expected several months of post-release work and then the project would go into maintenance mode.Then disaster struck. A pointy-haired boss somewhere up in a fuzzy area of the organization chart simply labeled “Here be VPs” discovered the large salary difference between American engineers and off-shore workers, and decided American engineers were far too expensive for software “maintenance”. The company decided to lay off 300 software engineers and hire 300 fresh-out-of-college replacements in a foreign country with much lower labor rates. The announcement was overshadowed by the fanfare of the product’s release and proudly billed as a major “win” for the company.Stephen was lucky enough to stay on and shift to other projects, the first of which was to assist with the transition by documenting everything he could for the new team. Which he did, in hundreds of pages of explicit detail, explaining how to use the source control repository for the project, execute and log unit tests, and who to contact when they had questions regarding the hardware itself. After that, he devoted himself to other projects. Months turned into years and Stephen assumed by the silence that the handover was successful and he’d never see the management app again.Of course that isn’t what happened.There’s an old joke on the Internet called “How to shoot yourself in the foot” (http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html) that lampoons the complicated process of shooting yourself in the foot in various programming languages. Here is one such entry:
CodeSOD: data-wheel="reinvented"
In HTML5, the data-* attributes were codified, and this is a really nice thing for building applications. They are an app-defined namespace to attach any sorts of custom data to your HTML attributes. For example, a div responsible for displaying a User object might have an attribute like <div data-user-id="5123">…</div>, which allows us to better bind our DOM to our application model. They can even be used in stylesheet selectors, so I could make a styling rule for div[data-user-id].I’m not the only one who thinks they’re a nice feature. Eric W has a co-worker who’s come up with a very… unique way of using them. First, he has the following Django template:
Test Overflow
WidCo was a victim of its own success. It had started as a small purveyor of widgets: assembling, storing, transporting, and shipping the widgets to their small client base in their podunk state. They'd once had the staff to fill orders placed by phone. As they'd begun to make a name for themselves in the surrounding tri-state region, however, their CEO had caught wise to the value of "this Internet thing."Within a decade, they were not only the country's foremost producer of widgets, but their entire staff makeup had changed. They now had more employees in IT than the other departments combined, and relied on in-house software to manage inventory, take orders, and fulfill them in a timely fashion. If the software went down, they could no longer fall back on a manual process.And—as the IT manager was fond of pointing out in budget meetings—they had a QA department of 0 and no automated tests.Bug reports piled up. Who had time to fix bugs? Monday was for scrambling to remedy production incidents after the weekend's jobs ran, Tuesday was for slapping together something sensible out of requirements documents, Wednesday for coding, Thursday for manual testing, and Friday for shoving half-tested code into production. Agile!Finally, over the post-Christmas slump, the IT manager managed to convince the CTO to bring in a trainer to teach developers about "improving our unit tests". All 0 of them.Adding tests to existing code was deemed a waste of time. It compiles, therefore it works. Begrudgingly, the CTO admitted that unit tests might be a good idea for new applications. Sometime in the next decade, they were bound to build a new application. They'd do this testing thing then.Desperate, the IT manager put in place a code review policy: before anything could be deployed, someone had to look at it. But they were checking only the changes, the CTO pointed out. It was a waste of time to examine working code in production. Standards were seen as just documentation, and documentation was waste. Look at the existing code and do more of that."Think lean," the CTO said.The IT manager sighed and hung his head.And then a lucrative new contract was signed: WidCo would be selling widgets in Canada as well. When their distribution partner expressed concern about the lack of a QA department, the CTO loudly proclaimed that all their developers had QA training, and they were bringing in an engineer to streamline the testing process. A position promptly opened under the IT manager, who was seen with an actual, honest-to-God smile on his face for the first time all year.Interview after interview was conducted. The first engineer was a bright young chap, a brunet with an easy smile and big round glasses. He started on a Tuesday, bringing in donuts to share with the team and promising to have things cleaned up within the week.Two days later, he handed in his resignation, crawled into a bottle, and refused to answer his phone, muttering about raw pointers and RAII. Later, the team found him waiting tables at the local pub, his bright smile turned into a sullen sneer.The second QA engineer was made of sterner stuff. She had the benefit of already being familiar with the code: she'd been brought in as a development contractor to save a project that was running over deadline earlier that year, and while she hadn't managed to work a miracle, she did impress the IT manager.By now, the CTO was so over the whole QA engineer thing. He was onto this newfangled "DTAP" standard, declaring that he'd stand up a Development server, a Test server, an Acceptance server, and a Production server, and all code would be promoted between them instead of going right from the developers' machines to prod.And so the QA Engineer rolled up her sleeves and tried to develop a sane promotions process. She set up an instance of Subversion and stuffed all the code into it. In order to comply with the standard, she made four branches: Dev, QA, Acceptance, and Trunk. Code would be done in dev, merged into QA for testing, merged into Acceptance for acceptance testing, and merged into Production to deploy. A daily cron job would push the code onto each server automatically. Continuous Integration!The build system complete, she could get to her main job: testing code on the Testing server. She sat the project managers in a room and explained how to test on the Acceptance server. Within a month, however, she was doing it for them instead.At least we're testing, she told herself, resigned to switching hats between "Try to break it" mode and "Is it actually nice to use?" mode when she changed servers.Of course, there were 30 developers and only 1 QA engineer, so she didn't have time to go through changes one by one. Instead, she'd test a batch of them on a weekly schedule. But by the time they were merged together and pushed to the servers, she had no idea which change was responsible for a test failing. So all the tickets in that batch would have to be failed, and the whole thing reverted back to the dev branch. Sometimes multiple times per batch.It was getting better, though. Every batch had fewer issues. Every code review had fewer comments. The QA engineer was beginning to see the light at the end of the tunnel. Maybe this would get to be so low-key she could handle it. Maybe she'd even be rewarded for her herculean efforts. Maybe she'd get a second helper. Maybe things would be okay.Then the CTO read an article about how some big-name companies had "staging servers," and declared that they ought to have one to improve quality. After code was accepted, code would then be deployed to the staging server for a round of regression testing before it could go live. Of course, since they had a dedicated tester, that'd simply be her responsibility.On the way out of that meeting, her heart sinking, the QA engineer was stopped in the hall by a project manager. "We've noticed a lot of tickets are failing," he began with a stern look. "That looks bad on our reports, so we're going to be running an extra round of testing on the dev server before it gets to you.""Oh, good, so maybe there'll be less tickets I have to send back," she said, raking a hand through her hair."Exactly," he said with a hint of a smile. "I'll forward the invite to you so you can sit in and give your feedback. It'll be 4 hours on Monday afternoon."Her efforts to weasel out of it were to no avail. She was the QA expert, after all, and her job was to train anyone who needed training. Henceforth, code would be checked into dev, tested by the project management group and the QA Engineer, moved to QA, checked by the QA Engineer, moved to Acceptance, checked by the QA Engineer, moved to Staging, checked by the QA Engineer, and then finally moved into production.After a few failure cycles in QA (somehow, the project managers weren't very effective at finding bugs), she was staying late into the evening on Friday nights, testing code as fast as possible so it could go to production before it was technically Saturday and thus overdue.Of course, because only she knew when the code was ready to move, the QA Engineer found herself in charge of merging between branches. And she had no idea what the code even did anymore. She never got to work with it, only seeing things from the UI level. And she was usually exhausted when she had to merge things. So there began to be a new class of error: merge errors, introduced by sloppy testers.The CTO had a brillant solution to that as well. He split up the shared libraries, making multiple copies of the repository. Each team would have their own stack of DTASP servers and their own version of source code. That way, they could deploy without having to merge code belonging to different teams. In addition to their existing separate dev instances, all 10 3-man teams would get 8 servers each: test, acceptance, staging, and prod, plus a database for each. And the QA engineer would have to test all of them.These efforts failed to make a dent in WidCo's bug backlog. However, the QA engineer made a killing running a betting pool in the breakroom. The odds were calculated fresh every Monday morning, and the payout went out when metrics were pulled on Friday afternoon. There was only one question to gamble on.Which was larger this week: the average time required to deploy a fix, or the average time for a developer to leave for a new job? [Advertisement] Incrementally adopt DevOps best practices with BuildMaster, ProGet and Otter, creating a robust, secure, scalable, and reliable DevOps toolchain.
CodeSOD: Keeping it Regular
Regular expressions are like one of those multi-tools: they're a knife, they're a screwdriver, they're pliers, and there's a pair of tweezers stuck in the handle. We can use them to do anything.For example, Linda inherited a site that counted up and down votes, like Reddit, implemented in CoffeeScript. Instead of using variables or extracting the text from the DOM, this code brought regular expressions to bear.
Error'd: The Duke of Error'd
"Ok, so what happens if I'm a duke? Then what?" wrote Adam S.
The Contractor
As developers, we often find ourselves working in stupid ways because the folks who were hired above/before us think that what they set up is ideal. While this happens in numerous industries, finance, especially at huge conglomerates, takes IT/Software-WTF to a whole new level. As contractors, we often get the we need your help in an emergency even though everything is unicorns and rainbows speech that precedes some meltdown for which they want you to take the blame.After taking a contract position at a large financial company, Bryan T. expected to see some amazing things. On the interview, they talked a big game and had even bigger budgets. It didn't take long to see some amazing things; but not the kind of amazing you'd think.To begin with, the managers and developers were still trying to roll their own time zones and caching. They didn't understand any of these terms: object graph, business intelligence services, concurrency, message pump, domain model, and well-defined. Bryan even needed to explain to them why JavaScript on random web pages doesn't have natural mechanisms to attach to .NET event handlers in other applications.Their head DBA explained that the difference between a uniqueness constraint and a primary key was semantics, and that audit records and current records should always be stored in the same table so as to keep related data together. They even used a simple text column to store City, State and Country, which led to obvious issues like three different values for the US ("US", "USA", "US_TOTAL").We all need to conform to some semblance of coding practices. These folks decided to use anti-coding-practices. For example, IEntity was a class but the "I" prefix was used because it was returned from an API.Shared common libraries were not allowed; if you needed to re-use a chunk of code, copy and paste it to where you need it; that's why they implemented cut-n-paste across applications!This also explains why SLOC is their primary productivity metric.There were no planned releases or scheduled iterations; whenever someone barked, a snapshot was manually copied from local builds.Perhaps most interesting of all, they had an awesome approach to branching. Instead of actually branching, they copied the whole code base into a new repository and ran that forward. Of course, this left a trail of repository droppings that you had to navigate.It took Bryan quite a while to acclimate to all of this. Then the team received a massive product request. Unfortunately, nobody understood the concept of scalability, let alone why it had to be considered. Instead, they decided that Cowboy Coding would be the M.O. of the project.At this point, Bryan decided he didn't want the job all that much. That very day, he had to work with another developer with whom he'd not yet had the pleasure. Their task was to return some JSON from a web service call. After more than a month of work, the other developer proudly showed Bryan what he had come up with to return specific data from the web service:
CodeSOD: Work Items Incomplete
Owen J picked up a ticket complaining that users were not seeing all of their work items. Now, these particular “work items” weren’t merely project tasks, but vital for regulatory compliance. We’re talking the kinds of regulations that have the words “criminal penalties” attached to them.What made it even more odd was that only one user was complaining. The user knew it was odd, their ticket even said, “Other people in my department aren’t having this issue, so maybe it’s something with my account?” Owen quickly eliminated their account as a likely source of the problem, but Owen also couldn’t duplicate the bug in test.A quick check showed him that the big difference between test and production was the number of work items. With a few experiments, Owen was able to trigger an infinite loop, when the number was very low. He dove into the code.
The Case of the Missing Signal
"My satellite connection is down," reported the user on the phone. "Can you help me?""Sure!" Omar, a support tech for a firm that supplied broadband by satellite, mentally suited up for his latest troubleshooting battle. The service he supported provided decent connection speeds to some remote geographic locations, but was far from perfect.After collecting some basic data from the user, Omar proceeded to explain the usual suspects. "Most likely, your dish is either blocked or not pointed correctly. High winds and bad weather are enough to push it out of alignment. Heck, I've even heard of toys, lawn furniture, all kinds of stuff knocking into dishes," he said with a chuckle. "How's your weather been lately, sir?""The weather's been good," the user replied. "Everything was working fine last night.""All right," Omar replied. "Well, the good news is that we have a portal we can use to see how the dish is doing and repoint it if necessary. Are you near your computer, sir? I'll help you open it."He walked the user through the process. The portal reported that the dish was healthy, but completely misaligned."No problem," Omar said. "We can use this portal to repoint the dish."Omar taught the user how to nudge the dish around with the portal's controls. Normally, this was a very fiddly process. In this case, no matter what the user did, the portal kept saying the dish was way off base.While chewing on a pencil, Omar began to wonder whether the dish was looking for the wrong beam. There were 83 of them, after all. Sometimes, customers moved their dishes into another beam area by mistake.But, no. According to the portal, neither the beam nor the hardware were problematic. The dish just wasn't getting a signal.Omar frowned. "Is there any chance you could go look at the satellite and make sure it's where it's supposed to be, with nothing obstructing it?""Well, OK," the customer replied reluctantly.A long, scratchy pause followed as the user moved around without muting his phone first. While Omar waited, he tried to think of further troubleshooting ideas, but he was getting desperate."Hey, I think there may be something in the line of sight after all!" the user reported with the breathless wonder of discovery."Oh?" Omar perked up, hopeful."We put the satellite on the quayside of the Clyde River. Looks like a ship has parked up overnight!""Oh." For a moment, simultaneous bafflement and relief stunned Omar. "Well, I ... think we're gonna have to wait for the ship to leave, then.""Yeah, guess so!" the user replied cheerfully."If it still doesn't work afterward, call us back, OK?""Will do! Thanks!"Fortunately, the problem never recurred. When he had some downtime, Omar quietly updated his team's Tech Support troubleshooting guide to include a new bullet point: CHECK FOR BLOCKING SHIPS.[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: Excellent Test
These days, you aren’t just doing development. Your development has to be driven. Business driven. Domain driven. Test driven.TDD is generally held up as a tool for improving developer efficiency and code quality. As it turns out, scholarly research doesn’t support that: there’s no indication that TDD has any impact at all. I have to wonder, though, if maybe that’s because people are still writing tests like this one, which Tomas received from an offshore contractor.
Error'd: Breaking News! (or Just a Test?)
"Hey, Angela! Helio is working!" writes Lawrence R.
Guaranteed LOC PITA
The task Tama set out to accomplish was rather straightforward. One of the clients had a legacy inventory management application, and they needed a simple text field added to an entry form.Though he'd never seen the code, and the word "legacy" sent chills through his spine, he was confident he could get it done quickly and painlessly. Without hesitation, he downloaded the sources and dug in to acquaint himself with the codebase.The database migration went easily, but the actual application—a WebForms solution spanning multiple projects and hundreds of files—turned out to be the strangest code Tama had ever seen. The first thing that caught his attention was an abundance of redundant and pointless code. Gems like
CodeSOD: A Rusty Link
Kevin did the freelance thing, developing websites for small businesses. Sometimes, they had their own IT teams that would own the site afterwards, and perform routine maintenance. In those cases, they often dictated their technical standards, like “use VB.Net with WebForms”.Kevin took a job, delivered the site, and moved onto the next job. Years later, that company needed some new features added. They called him in to do the work. He saw some surprises in the way the code base had changed.It was the “Contact Us” link that drew his attention. The link had a simple job: cause the browser to navigate to a contact form screen. A simple <a href=""> could handle the job. But that tech-savvy boss used this anti-pattern, instead.First, in the aspx file- the template of the view in WebForms, he added this button:<asp:LinkButton ID="lnkContactUs" runat="server">Contact Us</asp:LinkButton>Then, in the click event handler, he could do this:
All Zipped Up
Moving to version control is hard. It's a necessary step as a company grows into developing more complex software, with more developers working on the various products, but that doesn't make it any easier. Like all change, it's often delayed far too long, half-assed, and generally resented until everyone's forgotten about the indignity and moved on to complaining about the next improvement.For Elle's company, the days before Subversion consisted of a few dedicated PCs holding the source code for various customers, to ensure that none of them got mixed up with code for the others. By the time she joined, the company had long since moved to version control, but the source-controlled PCs remained, a curiosity to be laughed over.Then the budget cuts came, and the team continued to grow. In an effort to reuse the PCs, Hiro, the head of IT, decided to repurpose them as developer workstations. "This is all in version control, right?" he asked nervously. "I can wipe the box?""I'm not sure, but I can guess where the repo is if you want me to take a look." Elle knew most of the development was happening in newer codebases, the ones that'd been redone since the bad old days, and she wasn't sure if she even had access rights. Some of the older repositories were locked down weirdly, during a time when paranoia reigned and "security concerns" loomed."No, no, it's fine, I'll check myself. Just to be safe." He didn't tell Elle what he found, but the PC was missing the next day when the new guy started, so she figured it must have been there.Six months later, The Incident happened: their main competitor poached the five most senior staff, offering them better pay and benefits. Elle was jealous; apparently she was ranked number six on the team, and didn't get such a juicy offer herself. Still, she wished them the best of luck before they were frog-marched out to the parking lot by a furious Hiro. Security Concerns. According to the rumor mill, lawyers were brought in to prosecute the other firm for violating their non-compete. Life moved along, now with Elle training the new juniors hired to get the headcount back up.Two weeks after The Incident, Hiro stopped by Elle's desk. "Hey, remember PegasusCorp?" he asked, naming one of their older clients—one that hadn't required anything from them since before Elle had joined."What about them?" asked Elle suspiciously, smelling unpleasant work coming her way.Sure enough, they wanted some changes. The software needed a facelift. It seemed PegasusCorp's CEO had gotten a copy of Windows 8 and was loving the new "Metro" style. Elle rolled her eyes, but figured, whatever, a few visual changes shouldn't be too hard. She requested access rights to the old repo, checked out the trunk branch, and popped open the folder.She was faced with a single file: a neat, packaged zip. She blinked. What?She double-clicked on the zip, and it popped open a password entry field. What?!She tried the obvious things: password, admin, p@$$w0rd, the name of the company, the name of the product, even Pegasus. No dice. Frowning, she got up and went to ask Hiro.Hiro's eyes bulged and his face paled. "There's a what?!""A password on the zip file. Hey, if you don't know, I'll just ask ..." She trailed off. She was the most senior dev now, and she had no idea what the password could be. If the head of the department didn't know, that meant ..."Just call? Please? I'm sure they'll be reasonable," begged Hiro.Elle groaned as she trudged back to her desk, digging out the company off-hours cellphone directory. Whose bright idea was it to password-protect the damn source code?!She called the first of the five, and only got as far as, "I'm calling from CompanyName" before she was met with a furious expletive followed by a dial tone. She stared at the phone in horror. What had Hiro done to the guy?!The second person was more forthcoming, if not more helpful. "No way! Not unless you call off your lawyers. I had a great thing lined up, you ruined it, and now you come begging for help?"Elle had a sinking feeling about her remaining prospects, but had to keep calling. The third person had changed their number without updating the roster. The fourth was apologetic, but simply didn't know what the password was. The fifth just laughed and laughed until an unnerved Elle hung up the phone herself.God, I need a beer, she thought, lowering her head into her hands. How hard could it be to crack?Elle grabbed a dictionary file of English words and threw together a batch file with a handful of basic fuzz techniques: backwards, with digits appended, in l33t, etc. She let it run overnight, confident that she'd have an answer—and source code—in the morning.Beer time.But she didn't have the password in the morning. Or the next morning, or the next. By the time she left Friday night, she was seriously worried for her job. Hiro looked miserable and frantic, and her script was almost out of words to try.Monday morning, as she was rubbing the sleep from her eyes, Elle was startled by a loud thud. She lowered her hands, staring at the center-most table where ...Is that Hiro? she wondered. With a ... keg?!"Whoever can crack the PegasusCorp password gets this keg!" Hiro announced to the sleepy techs. "Have at ye!"By the end of the day, the source was revealed: resigning technician number five had been a huge Star Wars fan, and the password had merely been JengoFett. The keg was shared around the office, and come Tuesday morning, Elle was able to do the facelifts required.Meanwhile, the lawsuit backfired. The resigning staff got their jobs, and Elle's company had to pay for the suit, compensation for impounding their company vehicles, and salary up until their official resignation date.And life moved on, as it always does. [Advertisement] Universal Package Manager - ProGet easily integrates with your favorite Continuous Integration and Build Tools, acting as the central hub to all your essential components. Learn more today!
CodeSOD: Grumpy Cat
At the end of the lecture session, students immediately started packing up their laptops to race across campus for their next class. Andrew’s professor droned on, anyway, describing their assignment. “I’ve provided parser code,” he said, “so you can just download the datafile and use it.”He had more to say, but no one was paying attention. Perhaps he even had a correction to the assignment- because when Andrew went to download the data file for the assignment 404ed.Andrew emailed the professor, but figured- “Hey, I can get started. I’ll just read the parser code to understand the file format.”
Error'd: Let's Do the Timestamp Again!
"I am fairly certain that the data within this .csv file contains the secret of time travel," Merrick writes.
.gitignorant
Brent, who had started at JavaChip in QA several years ago, was tapped for “real” work with the core development team. On the day of his transfer, he gathered his things from his desk in a cardboard box, told his teammates in QA that he’d continue to see them for D&D at lunch, and trekked down the hall to the larger office.After finding his new desk, he went to find Karla, his team lead. As it turned out, Karla had called in sick, but she had sent Brent an email from home. Get settled in, she wrote. Our repo’s on the company git server. Make sure you have Maven and IntelliJ installed on your machine. Everything else is in the README.md file.Dutifully, Brent pulled down the repo. The size counter crept up. 10 MB … 20 … 30 …He had just pulled a 100MB repository onto his computer.Log JamThere was no conceivable way the repo should be that large.First, he imported the project into IntelliJ and built it with Maven, making sure there wasn’t anything wrong before he started tinkering. With no compiler errors or warnings, he opened WinDirStat and pointed it to the repo. The code relied on some hefty third-party libraries, but an initial scan revealed that those libraries didn’t take up more than 10MB. Including company-owned code, he had accounted for about 15MB of the 100MB repository size.Brent saw the bigger issue. In chrome red, faceted so small each file was about a pixel in size, were over 85MB of log files. They were generated by Maven and other parts of their compiler chain, written each time the project was built.Well, this should be easy, Brent thought. I’ll just add the log directories to .gitignore. Not bad for my first day on the team.Brent opened IntelliJ and dug around for a .gitignore file. Only there wasn’t one. He checked the root directory, in /src and other code directories, even a few libraries to make sure it hadn’t been put somewhere unusual. He even made sure IntelliJ wasn’t hiding “system” files, which .gitignore was sometimes treated as. There simply wasn’t one in the repo at all.Fair enough, he thought. I’ll just write one. Brent added a new .gitignore file in the root, put the log directories (and a few other suspect paths) into it, and submitted his first code change.A Sick Day RuinedBrent was feeling confident after his commit. He began rummaging through the repository, getting a feel for the codebase.However, sometime after lunch, Brent heard phlegmatic coughing from the entrance. Karla, the team lead, had come in on her sick day, and she was heading straight for Brent’s desk.“Brent, cough, we really need you to revert that commit.”“Why? I just added a .gitignore file.”“Right, that’s the problem. None of us here ever check in the .gitignore file.”“Don’t you want to configure your repo properly?”“We’re all pretty new to git, to be honest, but we had a big mess with conflicts when people were adding their own entries to the gitignore. Just revert and I’ll take care of it.”Reluctantly, Brent reverted his change.Ignore() Isn’t RecursiveAn hour later, he received an auto-generated email from the company git server: Karla had checked in a commit to the repo. The only change was to add a .gitignore file in the root directory. Thinking that she just preferred to write one herself, Brent opened the file in IntelliJ:
CodeSOD: Non-Threading
Reader Tyler shares this outstanding example of thread evasion:
Re-Relational
Given the rise of the internet in the mid 1990's, various events and companies led up to Adobe releasing Flash. Not to be out done, in the mid noughts, Microsoft created their own version called Silverlight. Somewhere down the road, Facebook, Instagram and others put forth React. These can sit on top of a webservice, like, for example,WCF to make it easier for web-facing programs to call home to interact with back-end applications to do useful things like display videos of cats being, well, cats. Occasionally, folks even attempt to use these tools to provide access to business applications.Some time back, Fred became a hired-gun/consultant/architect to a small financial company to help them replace a dying 150K LOC Silverlight UI with a React front-end, and the underlying WCF API (named Rest.Services for some reason). This allegedly trivial task was budgeted to take three months. Ten months down the road, Silverlight and the underlying code base were way ahead on points while the battle raged on. Eventually, management acquiesced and allowed the entire UI to be rewritten from scratch. The back-end, however...The application was a financial budgeting/reporting set-up. While it served its purpose from a business perspective, under the hood was a Cluster-O-WTFâ„¢ that simply would not cooperate with any attempts at change. Additionally, over time, the system became more and more obstinate about providing answers to queries. One morning, Fred noticed that the overnight updates were still running and the CPUs were pegged at 100%. A quick spelunk into the SQL showed why.Like every other financial system, there were multiple tables containing related data. One might expect each table to have a PK and the relationship-table to have a bunch of FKs.One would be wrong.Fred found multiple sets of tables, each with the following design pattern.
CodeSOD: Not the Shortest Shortener
Going through TDWTF inbox, I’ve built a sort of mental taxonomy of bad code. For example, there’s the kingdom of Tempus Malum: home-brew date manipulation functions, a rather profligate branch of bad code. Or the Order of Linguan Ignorans- bad code developed out of a complete ignorance of the available language features.There’s another category that I always consider a treat. It’s related to Linguan Ignorans, but also borrows from Quaesto Ignorat (ignorant of the problem being solved): Filo Annexa, or “Knotted String”, also known as “String All the Things!”Which brings us to today’s C# code, from Aaron.
Error'd: Workweek Hustle Shuffle
While my co-worker JR may have gotten the most steps, I still came out on top!
Editor's Soapbox: Programming is Hard
A bit ago, I popped into an “Explain Like I’m 5” thread to give my version of the differences between C, C++, Objective-C and C#. In true Reddit fashion, I had the requisite “no five year old could understand this” comments and similar noise. One thing that leapt out to me was that a few commenters objected to this statement: “Programming is hard.”The most thorough objection read like this:
CodeSOD: Every Possible Case
From reader Frank comes this delightful Java-flavored head-scratcher:
...39404142434445464748...