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.
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!
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:
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:
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:
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.
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.
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:
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.
"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!
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.
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
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:
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!
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.â€
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:
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.
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.
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:
It’s tempting to pick on PHP, because PHP is a terribly designed language. At the same time, there’s an air of snobbery and elitism in our mockery of PHP. I mean, half the Web runs on PHP, so how bad can it be? These examples could easily have been written in nearly any other language, and they’d be just as bad in those languages too. Is it fair to single out PHP? Perhaps not, but each of these examples does nothing- or nearly nothing- which may very well be PHP’s greatest asset.As a case in point, Ethan inherited some code. It needs to count how many sub-directories there are in a certain directory.
Steven worked for Integrated Machinations, a company that made huge machines to sell to manufacturers so they could actually manufacture stuff. He didn't build the machines, that would require hard physical labor. Instead, he wrote computer programs that interfaced with the machines from the comfort of the air-conditioned office. One such program was a diagnostic app used to log the performance of Integrated Machinations products. The machines didn't break down often, but when they did, logging was very important. Customers wouldn't be in a mood to hear that IM didn't know why the equipment they dropped fat stacks of cash on failed.Steven also had a subordinate named Thomas, who was foist upon Steven in an effort to expand the small development team. Steven could have easily handled everything himself, but Thomas needed something to do so he was given the simplest part of the diagnostic app - the downloader. Steven's code handled the statistical compiling, number-crunching, and fancy chart-making aspects of the application. All Thomas had to do was make the piece that downloaded the raw files from the machines to pass back.Thomas spent two months on something that would have taken Steven a week tops. It worked in their test environment, but Steven wanted to code review it went to production. Before he could, the higher-ups informed him there was no time. The logging and downloading system was installed and began to do its thing.Much to Steven's pleasant surprise, the downloader piece worked in the real world. Thomas had it set up to run every minute from Crontab on every machine their pilot client had. It passed back what the compiler needed in XML format and they had neatly-displayed diagnostic stats to show. This went on for a week, until it didn't.Steven came in that Monday to find that nothing had been downloaded over the weekend. As soon as Thomas meandered in, unshaven and bleary-eyed, he instructed him to check on the downloader. "Sure, if I can fight off this hangover long enough. Are you sure your stuff isn't broken??" Thomas replied, half joking, half trying not to pass out.Two hours passed, half of which Thomas spent in the bathroom. He finally came back to Steven's office to report, "Everything is back to normal! We lost all the logs from the weekend, but who works on the weekend anyway?" He quickly disappeared without further explanation.So began a repeating cycle of the downloader crashing, Thomas coming to work hung over, then fixing it without explanation. The Thomas problem got resolved before the downloader problem. He was relieved from his employment at Integrated Machinations after his sixth "no-call, no-show". This left Steven to support the downloader the next time it went down. It was completely undocumented, so he had to dig in.He found the problem was with the log file itself, which had bad XML for some reason. Since XML has a rigorously specified "Parse or Die!" standard, and Thomas wasn't much for writing exception handlers, the next time the downloader ran, it would read in the XML file, get a parse error, and die. It was at this point Thomas would have to delete the XML file, restart the downloader, and things would get back to normal.Digging in further, he found every time the downloader ran, it read and parsed the entire log file, then manipulated the parse tree and added a new <download> element after each record. Finally, it wrote the whole thing back to disk.
Ah, the ternary operator. At their worst they’re a way to obfuscate your code. At their best, they’re a lovely short-hand.For example, you might use the ternary operator to validate the inputs of a function or handle a flag. Adam Spofford found this creative use of the ternary operator in a game he’s developing for:
Recently, we featured the story of Alex, who worked in a little beach town trying to get seasonal work. But Alex isn't the only one with a job that depended entirely on the time of year.For most seasonal work in IT, it's the server load that varies. Poor developers can get away with inefficient processes for three quarters of a year, only to have it bite them with a vengeance once the right season rolls around. Patrick, a Ruby developer, joined an educational technology company at the height of revision season. Their product, which consisted of two C#/Xamarin cross-platform mobile apps and one Ruby/Rails back-end server, was receiving its highest possible traffic rates. On his first day at the office, the entire tech team was called into a meeting with the CEO, Gregory, to address the problem.Last year, the dev team had been at a similar meeting, facing similar slowness. Their verdict: there was nothing for it but to rewrite the app. The company had, surprisingly, gone in for it, giving them 6 months with no task but to refactor the app so they'd never face this kind of slowdown again. Now that the busy season had returned, Gregory was furious, and rightly so. The app was no faster than it had been last year."I don't want to yell at anyone," boomed Gregory, "but we spent 6 months rewriting, not adding any new features—and now, if anything, the app is slower than it was before! I'm not going to tell you how to do your jobs, because I don't know. But I need you to figure out how to get things faster, and I need you to figure it out in the next 2 weeks."After he left, the devs sat around brainstorming the source of the problem."It's Xamarin," said Diego, the junior iOS Dev. "It's hopelessly unperformant. We need to rewrite the apps in Swift.""And lose our Android customer base?" responded Juan, the senior Mobile Dev. "The problem isn't Xamarin, it's the architecture of the local database leading to locking problems. All we have to do is rewrite that from scratch. It'll only take a month or so.""But exam season will be over in a month. We only have two weeks!" cried Rick, the increasingly fraught tech lead.Patrick piped up, hoping against hope that he could cut through the tangled knot of bull and blame. "Could it be a problem with the back end?""Nah, the back end's solid," came the unanimous reply.When they were kicked out of the meeting room, lacking a plan of action and more panicked than ever, Patrick sidled up to Rick. "What would you like me to work on? I'm a back end dev, but it sounds like it's the front end that needs all the work.""Just spend a couple of weeks getting to grips with the codebase," Rick replied. "Once exam season is over we'll be doing some big rewrites, so the more you know the code the better."So Patrick went back to his desk, put his head down, and started combing through the code.This is a waste of time, he told himself. They said it was solid. Well, maybe I'll find something, like some inefficient sort.At first, he was irritated by the lack of consistent indention. It was an unholy mess, mixing tabs, two spaces, and four spaces liberally. This seriously needs a linter, he thought to himself.He tried to focus on the functionality, but even that was suspect. Whoever had written the backend clearly hadn't known much about the Rails framework. They'd built in lots of their own "smart" solutions for problems that Rails already solved. There was a test suite, but it had patchy coverage at best. With no CI in place, lots of the tests were failing, and had clearly been failing for over a year.At least I found something to do, Patrick told himself, rolling up his sleeves.While the mobile devs worked on rebuilding the apps, Patrick started fixing the tests. They were already using Github, so it was easy to hook up Travis CI so that code couldn't be merged until the tests passed. He adding Rubocop to detect and correct style inconsistencies, and set about tidying the codebase. He found that the tests took a surprisingly long time to run, but he didn't think much of it until Rick called him over."Do you know anything about Elastic Beanstalk auto-scaling? Every time we make a deployment to production, it goes a bit haywire. I've been looking at the instance health, and they're all pushing 100% CPU. I think something's failing out, but I'm not sure what.""That's odd," Patrick said. "How many instances are there in production?""About 15."Very odd. 15 beefy VMs, all running at > 90% CPU? On closer inspection, they were all working furiously, even during the middle of the night when no one was using the app.After half a day of doing nothing but tracing the flow, Patrick found an undocumented admin webpage tacked onto the API that provided a ton of statistics about something called Delayed Job. Further research revealed it to be a daemon-based async job runner that had a couple of instances running on every web server VM. The stats page showed how many jobs there were in the backlog—in this case, about half a million of them, and increasing by the second.How can that work? thought Patrick. At peak times, the only thing this does is make a few jobs per seccond to denormalising data. Those should take a fraction of a second to run. There's no way the queue should ever grow this big!He reported back to Rick, frowning. "I think I've found the source of the CPU issue," he said, pointing at the Delayed Job queue. "All server resources are being chewed up by this massive queue. Are you sure this has nothing to do with the apps being slow? If it weren't for these background jobs, the server would be much more performant.""No way," replied Rick. "That might be a contributing factor, but the problem is definitely with the apps. We're nearly finished rewriting the local database layer, you'll see real speedups then. See if you can find out why these jobs are running so slowly in the meantime, though. It's not like it'll hurt."Skeptical, Patrick returned to his desk and went hunting for the cause of the problem. It didn't take long. Near the top of most of the models was a line like this: include CachedModel. This was Ruby's module mixin syntax; this CachedModel mixin was mixed into just about every model, forming a sort of core backbone for the data layer. CachedModel was a module that looked like this:
“This is part of a home-grown transpiler…â€, Adam wrote. I could stop there, but this particular transpiler has a… unique way of deciding if it should handle module imports.Given a file, this Groovy code will check each line of the file to see if it includes an import line, and then return true or false, as appropriate.
Let’s take a moment to talk about documents. I once worked on an application that needed to generate some documents for Sarbanes-Oxley compliance, and without confessing to too much of a WTF, let’s just say it involved SQL Server Reporting Services, SharePoint, and some rather cryptic web service calls that I’m almost certain have stopped working in the years since I built it. The solution belongs here.I bring this up, because I’m happy to announce a new sponsor here at TDWTF: Atalasoft, which would have kept me from writing that awkward solution.Atalasoft makes libraries for working with documents from your .NET applications. There are SDKs for manipulating images, working with PDFs, and mobile SDKs for doing document capture on iOS or Android devices, and WingScan provides interaction with TWAIN scanners right from inside of a web browser. Their products provide zero-footprint document viewing, easy interfaces for constructing and capturing documents, and come with top-tier support for helping you get your application built.This sponsorship coincides with their latest release, which partners with Abbyy’s FineReader to add OCR support, the ability to interact with Office documents without Office installed, new PDF compression options, and a variety of improvements to their already excellent controls and SDKs.[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!
In my formative years, I had experienced such things as Star Trek, and the advent of new games like Pong, Space Invaders and Asteroids. As I ventured out of college and into the Orwellian future of 1984, I began a 3+ decade long sojourn into the world of technology. I mused about the wondrous changes that these new-fangled gadgets would bring to all of our lives. Telescreens that connected us both visually and orally in real time. Big Brother. History could be rewritten. Technology would boldly take us where no one had gone before... Hollerith cards were replaced with Teletypes, then CRTs and finally flat panel displays. You can still fold, spindle and mutilate a flat panel display; it just takes more effort.Pneumatic tubes were replaced with email and finally text messages. Try as you might, there's simply no way to text someone a live critter.Interactive Voice Response systems. Talking to a helpful customer service representative is no longer necessary now that we can listen to a recording droning on. After all, don't you just love doing a depth-first search through 17 sub-menus to get what you want?ARPANET d/evolved into the internet. Google has eliminated the need to have bookshelves of manuals, or remember anything you've ever posted - because it's all there in perpetuity. Granted, a lot of it is filled with pron, but you don't actually have to look at it!Programming languages. We went from assembly to FORTRAN to C to C++ to Java/.NET/... to scripting languages. While it's true that auto-GC'd languages make it easier to concentrate on what the program must do instead of interfacing with the machine, VB/PHP/Excel/etc. brought programming within reach of those who should not have it. COBOL lives on (as it turns out, the Enterprise does have a mainframe)Communication. Snail-mail was slow. Email sped things along, but we got impatient so they invented texting. Apple leap frogged a great idea, but only for the truly nimble-fingered. They still haven't gotten dictation-transcription to work properly; we're nowhere near the point of saying: Computer, build me a subroutine to... because the replicator would spit out a submarine.Security: Challenge-response questions aren't a bad idea, but too often all the allowed questions can have multiple answers, which forces you to write the Q/A down and keep them nearby (I don't have an older cousin, neither of my parents has a middle name, my first pet was twins and the place I met my wife was in a village in a township in a district in a county).Security: Requirements that vary wildly for the password-make-up, and change-frequency from system to system and company to company (requisite link).Hmm, 4-8/6-12 characters? Numbers/upper/lower case? Subsets of: ~!@#$%^&*()_+-={}[]:;"',.?/) Change it every 4/6/8/12 weeks? Maybe I'll just go with the fail safe PostIt. FWIW: I haven't had to change the password on my bank ATM account in 35 years because I. Don't. Tell. It. To. Anyone.Now that the government has shown that any device, no matter how secure, can be cracked, we must all realize that encryption, no matter how sophisticated, ain't cutting it...Security: We could just write everything in Perl; it would be completely secure after 24 hours (even without encryption) as nobody (including the author) would be able to decipher it (missed opportunity).Editors: edlin, notepad, vi: when they were all you had, they were a blessing. Notepad++, vim, IDEs, etc: big improvements. But with convenience comes dependency. I once had to edit a config file for a co-worker because they couldn't figure out how to edit it on a *nix production system where Emacs wasn't installed!Smart phones allow you to concentrate on that all-important email/text/call instead of driving. You can play games (like Pokemon-GO) while behind the wheel, so you can crash into a police car.Of course, how many times have you texted someone about something only to end up sending an auto-corrected variant (Sweetheart, I'm going to duck you tonight).Smart cars allow your navigation system to blue screen at highway speeds. This happened to my CR-V, and the dealer told me to disconnect the main battery for 30 seconds in order to reboot the car.The computer can also modify your input on the gas pedal to make the car more efficient. This sounds like a good thing. Unless you stomp the accelerator through the floor (clearly demanding all the power the engine can give) and the computer decides otherwise, which leads to some very WTF looks from the truck driver that almost pancaked you.Smart appliances: we no longer need to pester our spouses because, while at the supermarket, we can now contact our appliances directly to see if we need this or that. This will inevitably lead to weekly security-updates for our cars and appliances (you know the day is coming when your fridge and coffee maker start to automatically download and install a Windows-10 update).Games: from Conway's Life to Sim*, Tetris to Angry Birds, the assorted 80's video and arcade games, Wolfenstein/Doom/Quake/etc., and everything that followed. Games have drastically improved over time and provide tremendous entertainment value. They have yet to build a computer that can count the number of hours of sleep lost to these games.Miniaturization: they spent zillions creating monstrously large flat panel TVs and then zillions more to get us to watch movies on our phones. After they spent zillions making stuff smaller, they flooded those smaller devices with ads for stuff to enlarge things.These topics were chosen randomly while thinking back on my career and wandering around my house, and of course, there are many more, but rather than having made drastic improvements in our lives, the changes seem oddly even...On the other hand, I don't recall Scotty ever having to download a Windows update, and Lt. Uhura never got a robo-call from someone in the Federation (Enterprise: if you would like a scan of the 3rd planet of the system in sector 4, press 3), so maybe the future will be brighter after all.[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!
This anonymous submission is the result of our submitter decompiling a Flash application to see how it worked. It’s not often that one thinks to himself, “Wow, some case statements would’ve been a lot better,†but here we are.
Maintenance programming is an important job in nearly any software shop. As developers move on to other positions or companies, the projects they leave behind still need someone to take care of them, to fix bugs or implement customer requests. Often, these products have been cobbled together by a variety of programmers who no longer work for the company, many of whom had only a loose understanding of the product (or even programming in general).Martin was one such maintenance programmer. After being hired, management quickly realized he had a knack for digging into old systems and figuring them out well enough to update them, which often meant a full rewrite to make everything consistent and sane.One such system that quickly fell into his lap was essentially a management appliance, a Linux virtual machine (VM) prepackaged with a web-based management interface to control the system. The web application worked well enough but the test suite had…trouble.The tests used Selenium to deploy a fresh VM and perform some pre-defined actions on the user interface. Most of the test suite was written by a former employee named Jackson who, as far as Martin could tell from his notes and source control commit messages, had very odd assumptions about how things worked, especially involving concurrency.The test suite had some serious performance issues, as well as a ton of inexplicably failing test cases. The system did not scale up as more VMs were deployed, at all, and Martin uncovered the scary truth that Jackson had wrapped everything in synchronization primitives and routed all actions through a global singleton which stored all state for all VMs. Only one test operation at a time was supported, across all test VMs, forcing them to queue up and run sequentially.Seeing how all test state was stored in a global singleton, Martin realized that a huge number of the test suite’s failures had to do with leaky state. One test VM would set some state, then give up its lock between tests, providing a small window for another VM to grab the lock and then fail because the state wasn’t valid for that specific test.He asked around the office to see if anyone knew more about the test system, and though nobody knew the specifics, his coworkers did recall that Jackson was hugely concerned that state would leak between test VMs and cause problems and had spent most of his time designing the system to avoid that. So Martin started reviewing source control history and commit messages, and found that Jackson was ignorant of anything beyond basic programming. Somehow, he believed the singleton would prevent state from being shared. Commit messages spelled it out: “Used a singleton to avoid shared state for concurrency.â€And so Martin spent a few months improving the system by removing the singleton and mutexes, and generally cleaning up the tests’ code. During testing, Jackson’s shared state woes never surfaced, and when Martin was finished the test suite scaled very well by the number of VMs. Most of the spurious test failures simply disappeared and the entire suite ran in a fraction of the time.And now Martin understood why Jackson was no longer with the company. His solution for dealing with concurrency problems from “potential†shared state was to rewrite the framework to use “assuredly†shared state. [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.
C++ is a language with a… checkered past. It’s grown, matured and changed over the decades, and modern C++ looks very little like the C++ of yesteryear. Standard libraries have grown and improved- these days, std feels nearly as big and complicated as parts of Java’s class library.One useful function is std::toupper. Given a char, it will turn that char into an upper-case version, in a locale-aware fashion. What if you want to turn an entire string to upper-case?You might be tempted to use a function like std::transform, which is C++’s version of “mapâ€. It alters the string in-place, turning it into an upper-cased version. With a single line of code, you could easily convert strings to upper-case.Or, you could do what Tomek’s highly-paid consultant did.
In a good organization, people measure twice and cut once. For example, an idea is born: let's create a data center that is set up properly. First, you figure out how much equipment is needed, how much space is required and how much power is needed to run and cool it. Next, you size back-up batteries and fuel-powered generators to provide uninterruptible power. And so forth.In a good organization, each of these tasks is designed, reviewed, built, tested and verified, and approved. These things need to be right. Not sort-of right, but right!Close only counts in horseshoes, hand grenades and thermonuclear war.Here's a tale of an organization doing almost everything right... almost.In the late noughties, Mel was working at something that wasn't yet called DevOps at a German ISP. It was a pretty good place to work, in a spanking new office near the French border, paid for by several million customers, a couple of blocks from one of the region's largest data centers that housed said customers' mail and web sites. The data center had all kinds of fancy security features and of course a state-of-the-art UPS. 15 minutes worth of batteries in the basement and a couple of fat diesels to take it from there, with enough fuel to stay on-line, in the true spirit of the Internet, even during a small-time nuclear war. Everything was properly maintained and drills were frequently held to ensure stuff would actually work in case they were attacked or lightning hit.The computing center only had a few offices for the hardware guys and the core admin team. But as you don't want administrator's root shells to be disconnected (while they were in the middle of something) due to a power outage either, they had connected the office building to the same UPS. And so as not to reduce the backup run time unnecessarily, there were differently-colored outlets: red for the PCs, monitors and network hardware, and gray for coffee makers, printers and other temporarily dispensable devices that wouldn't need a UPS.Now Germany happens to be known as one of the countries with the best electric grid in the world. Its "Customer Average Interruption Duration Index" is on the order of 15 minutes a year and in some places years can pass without so much as a second of blackout. So the drills were the only thing that had happened since they moved into the office, and not being part of the data center, they weren't even involved in testing. The drills were frequent and pervasive; all computer power cut over to batteries, then generators, and it was verified at the switch that all was well. Of course, during the tests, land-line power was still present in the building on the non-UPS-protected circuits, so nothing actually ever shut off in the offices, which was kind of the whole point of the tests.When it inevitably hit the fan in the form of an exploding transformer in a major substation, and plunged a quarter million people into darkness, the data center kept going just fine. The admins would probably have noticed a Nagios alert about discharging batteries first, then generators spinning up and so forth. The colleagues in their building hardly noticed as they had ongoing power.However, on Mels' floor, the coffee maker was happily gurgling along in the silence that had suddenly fallen when all the PCs and monitors went dark.It turned out that their floor had been wired with the UPS grid on the gray outlets from the beginning and nobody had ever bothered to test it. [Advertisement] Otter enables DevOps best practices by providing a visual, dynamic, and intuitive UI that shows, at-a-glance, the configuration state of all your servers. Find out more and download today!
We write a lot about unhealthy workplaces. We, and many of our readers, have worked in such places. We know what it means to lose our gruntle (becoming disgruntled). Some of us, have even been tempted to do something vengeful or petty to “get back†at the hostile environment.But none of us actually have done it (I hope?). It’s self defeating, it doesn’t actually make anything better, and even if the place we’re working isn’t, we are professionals. While it’s a satisfying fantasy, the reality wouldn’t be good for anyone. We know better than that.Well, most of us know better than that. Harris M’s company went through a round of layoffs while flirting with bankruptcy. It was a bad time to be at the company, no one knew if they’d have a job the next day. Management constantly issued new edicts, before just as quickly recanting them, in a panicked case of somebody-do-something-itis. “Bob†wasn’t too happy with the situation. He worked on a reporting system that displayed financial data. So he hid this line in one of the main include files:
In most companies, business growth leads to greater organizational complexity. With more clients to juggle, owners must increasingly delegate less important tasks to a growing pool of employees and lower management. With time, the org charts grow from simple diagrams to poster-sized trees. Departments and SBUs become separate entities. What was once a three-man startup morphs into the enterprise behemoth we all know and love.For Vandelay Books, however, this was not the case. Despite becoming one of the largest book distributors in the state, the owners—a husband and wife pair of successful enterpreneurs—kept a firm grip on every single aspect of business. While it helped to alleviate many of the problems found in large enterprises, it also meant several departments were severely understaffed and barely managed. The internal software department, in particular, consisted of a single developer and an occasional intern or contractor ever since the company had started operating.While it looked like a recipe for disaster, Vandelay Books had two redeeming features: they were hiring, and paying handsomely. For desperate George, who'd nearly exhausted his unemployment emergency fund, all it took was to shake hands with the couple and sign the contract. From there, it was on to a brighter future, assisting with the migration of the company's software suite from an ancient and unsupported database to something more modern.After setting up his desk and workstation, the owners led George to a grey-haired, scruffy man sitting at the other end of the room."This is Doug, our lead developer," the husband introduced."Pleasure to meet you." Doug stood and shook George's hand, smiling from ear to ear. "Have you settled in already?""I think so, yes," George said. "All I need is a copy of the database to work with.""I'll get it for you as soon as possible." Doug turned towards his PC and started typing.After exchanging a few more words with the owners, George left for his desk, expecting the database copy to be waiting in his inbox.An hour later, George had grown impatient. What's taking him so long? he wondered. It shouldn't take more than a few minutes to run a build script.He decided to remind Doug about the copy. Doug was at his desk, furiously whacking at the keyboard and grinning to himself."Hi, how's that database coming along?" George asked, trying to hide his irritation."Almost done!" Doug took his hands off the keyboard, his lips still curved in a beaming smile. "Sorry to keep you waiting, there's a lot of tables in here.""What do you mean, lots of ...?" George began, but a quick glance over Doug's shoulder answered his question. Instead of a shell window or a database IDE, Doug's display consisted of nothing but a large Notepad window, with the cursor placed in the middle of an unfinished CREATE TABLE statement.No wonder it takes so long when you're typing the entire database out! George barely held back from screaming at his coworker. Instead, he stepped away as casually as possible and opened his IDE, morbidly anticipating the horrors lurking in the codebase.A quick skim through the code made George realize why Doug was always smiling. It was the blissful smile of complete and utter ignorance, the smile of someone who'd risen far beyond their level of incompetence and was now eternally grateful for every day things didn't fall apart.And the code looked like it could fall apart any minute. Over 300,000 lines had been thrown together without rhyme or reason. Obviously, Doug hadn't heard of such modern concepts as "layers" or "structured code," instead opting to hack things together as he went along. Windows API calls, business code, inline strings and pieces of SQL—everything was shoved together wherever it would stick, creating the programming equivalent of a Katamari.George sat there, pondering all the wrong decisions in his life that'd led to this Big Ball of Mud, until Doug appeared beside him and shook him out of his stupor."Oh, I see you're already looking at the code!" Doug said. "It's not that hard to understand, really. I even have a few flowcharts that could help you out! Anyway, you just need to go through each of these commands, one by one—remember, it's not really SQL—like here, when it says SELECT with no FROM like this? It's actually a DELETE. And so on. Simple, isn't it?"His head spinning, George decided to risk it. "Actually, I was thinking we could structure it a little. Separate those calls out, make a few functions that read or insert records—""I beg your pardon?" Doug's smile faded, giving way to the surprised look of a deer in headlights."I mean ... uh, never mind."Sure, the migration would take a hundred times longer Doug's way—but as long as the paychecks cleared, it wasn't worth it to George to fix the unfixable.Days passed slowly at Vandelay Books, and George's heroic efforts slowly paid off. The code was still terrible despite numerous attempts to improve it when Doug wasn't looking, and the migration wasn't even close to being completed, but George could finally pay his bills and refill his accounts. Once in a while, the owners would stop by for a friendly chat. Between that and the relaxed atmosphere, George began to enjoy the company, if not the job he was tasked with.Eventually, during one of the conversations with the owners, George felt confident enough to mention that there was a way to get the migration done faster and more efficiently. He hoped they'd be able to convince Doug to let him have more freedom with refactoring the code, or at least fixing some of the most offensive spots.Instead, all he got were puzzled looks and a long, uncomfortable silence.The next day, the husband approached him as soon as he entered the office."George." The owner's voice was dry and stern. "We've discussed what you said yesterday with Doug, and we've decided we won't be needing your services anymore. Please clear out your desk by today."George didn't bother arguing. He quietly packed his things, said his goodbyes, and headed back home to polish his resume again. And although he soon found a job at a much more sanely managed company, he often wondered if Doug were still migrating the application one query at a time—and whether he was still able to smile. [Advertisement] Otter enables DevOps best practices by providing a visual, dynamic, and intuitive UI that shows, at-a-glance, the configuration state of all your servers. Find out more and download today!
Many times, when we get a submission of bad code, we’re left wondering, “what else is going on here?†Sometimes, you think, “if only I knew more, this would make sense.†More often, you think, “if I knew more, I’d be depressed,†because the code is so clearly bad.For example, Devan inherited a report, built using SQL Server’s Reporting Services Report Builder tool. Now, this tool is not intended as much as a developer tool, as a “if you can use Excel, you can make a report!†It uses Excel-style functions for everything, which means if you want to have branching conditional logic, you need to use the IIF function.Just don’t use it like this.
"The date is in the past and there is no time zone specification," writes Hugo K. "But apart from that, everything in this invitation is clear as...verterem mediocritatem?
Port-au-Prince, I wanna catch a glimpse ...Summer's winding down, and we're inexorably approaching the fall. Did you take a vacation this year, reader? Maybe you went to the beach; or maybe you live on the beach and you went to the mountains instead, as I did as a girl. Wherever you may have gone, odds are it was a tourist destination. Do you ever wonder what they get up to the rest of the year?Alexi grew up in just such a tourist town, a little oceanic getaway that was a sleepy ghost town for most of the year, propped up by the brief yet intense tourist season. Her last year of high school, she tried desperately to find a co-op position, but her options were bleak and limited. Finally, she landed the only job she could: the IT guru for the local community college.At first, it wasn't so bad. She spent much of her time reading books in the office, waiting for the hapless student with wifi troubles or the clueless teacher who needed a password reset. The highlight of her career was the day her senior tech, Aaron, turned off Spanning Tree protocol on a router and then flipped it all back on at once, causing a small fire in the broom closet they were using as a server room.But for the most part, her days were quiet. Almost ... too quiet.Jack was a department head, one who was well known by the IT staff. When he stopped by, Aaron immediately ducked into the broom closet. Alexi frowned briefly, but by the time she turned around, she was ready with a polite expression and her asshole-handling kill-'em-with-kindness tone. Her time in retail had prepared her for such a customer."Can I help you, sir?""Yes, I'm having some trouble with this newfangled Internet classroom," Jack said. "Can you help me?"No cursing, sputtering, or calling her useless? Then why was Aaron hiding?"Of course," Alexi replied. "What seems to be the trouble?""Well, I set up the microphone and camera just like your instructions said, but my students say they can barely hear me. I even turned up the volume, and nothing."Now suspecting this to be the oddest prank ever, Alexi launched into the standard bevy of questions. "What kind of microphone are you using?""I have a broadcast microphone from the telecommunications department, plugged into about 300 feet of cable."That was weird, but not unheard of; there was plenty of old equipment floating around. "All right, and where does the cable plug into?" she asked, expecting an audio interface of some type to be involved."What do you mean?" Jack asked, a polite yet puzzled expression adorning his face."Well, you said there was 300 feet of cable, right? It has to be plugged into something.""I thought it was wireless."Wireless? With that long of a cord? "No. That's why it has 300 feet of cable ..."Sensing that they were both confusing each other more than before, Alexi closed her laptop and asked the gentleman to show her the setup.The classroom Jack was using was a large lecture hall, complete with a chalkboard and podium. There was a desktop machine sitting under the podium, but Jack had elected to use his own laptop on top of the podium instead, with the camera clipped to the hinge. He demonstrated for her that he was speaking loudly enough as he dragged the microphone, entirely untethered, around the stage area.A 300-foot tail of black cable dutifully followed him to and fro, but surely was not capable of conveying sound to his laptop. The crappy built-in microphone on the laptop itself, however, was more successful in picking up his voice. [Advertisement] Infrastructure as Code built from the start with first-class Windows functionality and an intuitive, visual user interface. Download Otter today!
Good intentions are never enough. If they aren't coupled with the wisdom to follow through properly, they can result in a horrible mess. Today’s Anonymous submitter has learned this the hard way:
Old Peter’s company has a legend. It has been passed down through generations of programmers and staff through an oral tradition. Oh, from time to time, someone would be inspired to record the tale for posterity, but inevitably, the hard copy was recycled, the digital copy was lost.It was 1982, and the German tech industry was booming. Old Peter’s company manufactured a line of 8-bit computers that were targeted towards businesses. Their targets were generally larger companies and government organizations- like Frequenzhof Busgesellschaft.Frequenzhof Busgesellschaft - the bus company of Frequenzhof - served a bustling metropolis in the heart of Germany. They had a growing ridership and a growing need to automate their accounting processes. They bought one cabinet-sized 8-bit microcomputer and if they liked it, planned to buy another. With the addition of tape drives and other accessories, the Busgesellschaft was going to be a very valuable client.So when the director of the bus company called support, people jumped to solve their problem. Unfortunately, it was easier said than done:“When we use your computer to run our weekly batch process, all of our radios stop working. We cannot communicate with our drivers! This is unacceptable!â€The technician tried to clarify the problem. “I’m sorry, but… if you run an accounting job, the radios stop working? Our computer doesn’t have anything to do with your radios!â€â€œAnd yet, when we turn on your computer, the radios stop working! We think it must be interference.â€â€œThat… that really can’t be.†A computer, of course, does throw off some electromagnetic fields- anything using electrical current did. But to kill a voice radio network? That seemed implausible.The technician gathered more details, and then escalated. Management didn’t want to lose future sales, and got defensive about their system. It relatively well shielded, and the frequencies it generated- all harmonics of the 1MHz chip running in the system, or of the 50Hz mains power- were nowhere near common voice frequencies.Over the next few months, a series of radio and electronics technicians examined the situation. They tested a computer right as it came off the assembly line, proving that it didn’t radiate any significant EM noise, especially not at the bands the radios used (≈ 26MHz - 27MHz). The company, eager to keep their customer happy, replaced the “defective†computer with a fresh one, confident that this would solve the problem.It didn’t.Frequenzhof Busgesellschaft grew increasingly concerned. This computer was an expensive capital asset, and they couldn’t use it without cutting communications with their drivers- what if there were an accident or an emergency? Fingers were pointed, blame was doled out, and the Busgesellschaft threatened to take their business elsewhere.The computer company begged for one last opportunity to send in a technician, because obviously there was something extremely unusual going on. “This shouldn’t be happening,†they agreed, “but work with us to fix it.†So they sent Fritz out to the customer site.Fritz was an expert in radio systems. Rumor had it that, before he entered the private sector, he had been working in signals intelligence, spying on the Russians. Whether or not there was any truth to the rumor, he was considered one of the best in his field. If he couldn’t solve the problem, no one could solve the problem.When Fritz’s car pulled up to the bus company’s building, he had a suspicion as to what might be wrong. When he entered the computer room, and saw the computer was positioned against an exterior wall, he knew what was wrong. This was, after all, 1982. In Germany. Frequenzhof Busgesellschaft was housed in a late 1960s slab of brutalist concrete. Hidden inside of that concrete was structural rebar. The computer’s tiny EMF resonated with the rebar grid, creating a chain of harmonics that laid static over the radio system, killing communication.Fritz’s solution was as elegant as his diagnosis: relocate the computer to the middle of the room, far enough away from the rebar that it couldn’t couple with it. They followed his instructions, and it worked perfectly- even when they did get around to adding that second computer.[Advertisement] Release!is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped!
Paulo F was doing a little online banking with one of the largest banks in Brazil. He wanted to buy a pre-paid debit-card. He chose a value from the drop-down, for example R$50,00- fifty Reals. The site promised him a card loaded with R$200,00. It didn’t matter what he chose, the site offered him a completely different value.Curious, he pulled up the element in the inspector.