Recent Articles

Jul 2023

Just a Copy of Copy

by in CodeSOD on

I don't think anyone would argue that BASH provides a good scripting environment. It provides a commonly available scripting environment that even its successor shells attempt to emulate. But it's idiosyncratic, at best, and leads to bug-prone scripts.

But there are certain tasks that it excels at- specifically, the kinds of tasks that you'd normally do from the shell but just want to wrap some light automation around. Want to scan a directory and then copy some subset of the files out based on user arguments? BASH is your friend! It's just some basic conditionals and some cp commands, what could be easier?


Total Zeroes

by in Error'd on

Today, scattered amidst the gems, you will find a whole bunch of zeroes. No, not the contributors!

The zeroeth submission of the day is from Bluejay A. who sagely notes "That shouldn't be too hard to find."


Fast Conversion

by in CodeSOD on

Clara had a database of users. The EmailAddress field in the user table was, by design, nullable, but some downstream applications didn't like nulls and wanted something there. Now, it didn't particularly matter what the values were, just that there were some, so Clara wrote up a quick stored procedure that would return the users with the null emails converted to the format BlankEmail_YYYYMMDD, e.g., BlankEmail_20230726.

This was all well and good until one of the senior developers decided that Clara's use of the T-SQL date functions was killing performance. They made this decision based on being the senior developer, but not based on any metrics or performance monitoring. Real seniors don't need such trivialities- they know what badly performing code is just by looking at it.


Base of the Hash

by in CodeSOD on

Jamie Kitson followed the instructions to integrate their software with a new payment provider. The payment API was fairly straight forward, mostly a straightforward call to a web endpoint. As an error check, the request required an base-64 encoded, MD5 hash of its contents appended to the end of it.

Jamie did just that, in C#. And the payment processor balked: the hash was wrong. There was no information beyond that, just "bad hash".


The Set Up

by in CodeSOD on

My heretical opinion on object-oriented programming is that I don't like getters and setters. They're often trivial boilerplate (boilerplate is a code smell), or they're hiding behavior where behavior probably doesn't belong.

Yes, yes, I understand the importance of encapsulation, but in a lot of ways, trivial getters/setters break encapsulation. void setFoo(T foo) { this.foo = foo; } does nothing to protect foo against unauthorized modifications.


The Apex of Development

by in CodeSOD on

David S writes: "I'm undertaking a refactor and facelift of an Oracle APEX application."

That, already, is the real WTF. Oracle Application Express, or APEX (formerly ApEx, formerly HTML DB) is Oracle's offering in the low-code business application space. Using a WYSISYG designer, you build pages and bind them to SQL queries, stored procedures, etc., allowing users with little to no programming experience to design data driven applications.


Only the Beginning

by in Error'd on

I have been surprised to find that some people who are in technology fields don't have a clear grasp on the difference between RAM and "disk" storage. Or perhaps more accurately these days, "Direct Access Storage Devices." I've eventually become accustomed to it from ordinary folks, but PC World?

An anonymous reader sent in this one, explaining "Yep. According to PC World Starfield will require 125 GB of available RAM so you'll need at least 128 GB or more RAM installed to play. The Steam page correctly list the item as Storage: 125 GB available space so this is completely on PC World. To add insult to injury the post is titled Bethesda’s Starfield PC system requirements: An SSD is mandatory so you'd expect at the very least to get the storage requirements right. Rush to print, trip and fall flat on your face. Thanks for the WTF, PC World!"


Paging the Bean

by in CodeSOD on

Today's an interesting case of code that seems perfectly reasonable at first glance. Sent to us from FinalGuy, this Java code caused no end of problems for him due to its rather unexpected behavior:

public void setCurrentPage(int currentPage) {
    if ( currentPage < 1 ) {
        currentPage = 1;
    }
    if ( currentPage > maxPages ) {
        currentPage = maxPages;
    }
    this.currentPage = currentPage;
}

Evaluating Tax Burdens

by in CodeSOD on

Many years ago, Westie's employer got hired to help a client rebuild their tax advice website. The current version was… not in good shape, didn't provide a good user experience, and was incredibly unmaintainable. Westie's mission? Rewrite it from scratch.

As these projects go, however, the requirements were ill documented, and basically were "Uh, just make it do all the same things, but it shouldn't suck anymore."


Universal Stream

by in CodeSOD on

Twenty years ago, Stefano Z worked with some Very Smart Very Senior Engineers. These Very Smart Senior Engineers liked to find all sorts of "interesting" solutions to common problems.

For example, they had a module in C++ that needed to send data to other systems. To formalize this messaging, they needed a set of Data Transfer Objects (DTOs). Now, there are many libraries that might make generating these kinds of objects easier, but the Very Smart Very Senior Engineers didn't want to use a library. So they started out with just large piles of hand coded:


DXL

by in Feature Articles on

Managing requirements for even a simple project is a nightmare. As projects get more complicated, "requirements management" mutates into "systems engineering". The requirements for, say, an entire IT migration, or an automobile, or a lunar lander turn into a tree of requirements, where each implementation step is traced back to an overall master requirement at the root of the tree. Five to one, your average project isn't this complicated, but you don't want to ship a product missing features and have to say "it slipped my mind".

Enter a certain large vendor's Dynamic Object Oriented Requirements System (DOORS). Doors allows the requirements for a large, complicated product, to be organized into objects which are further organized into modules, where each object is a requirement, paragraph, section, table, figure, or anything that explains the nature of requirements.


Time Keeps on Slipping

by in Error'd on

Warren D. takes the long view, explaining "I like a company that has an eye to the future. Maybe I'll stick with the Malwarebytes Premium trial for another few hundred thousand years."


edoced_46esab

by in CodeSOD on

Rick is supporting a Magento-based e-commerce site. As many such sites, it uses a lot of third party plugins. One of those third party plugins wants to make sure no one "steals" its code, and thus obfuscates the code.

$_F=__FILE__;$_X="JF9GPV9f...oJF9EKCRfWCkpOw==";$_D=strrev('edoced_46esab');eval($_D($_X));

Yearly Updates

by in CodeSOD on

C. Wiles has the "joy" of working on a SAS application for a large health insurance company. This snippet was extracted some time ago, but the application continues to live on. It has one job: pad the month part of dates to two digits. Let's see how it's done.

%macro yearmonth;
		if year_month = '2010-1' then year_month = '2010-01';
		else if year_month = '2010-2' then year_month = '2010-02';
		else if year_month = '2010-3' then year_month = '2010-03';
		else if year_month = '2010-4' then year_month = '2010-04';
		else if year_month = '2010-5' then year_month = '2010-05';
		else if year_month = '2010-6' then year_month = '2010-06';
		else if year_month = '2010-7' then year_month = '2010-07';
		else if year_month = '2010-8' then year_month = '2010-08';
		else if year_month = '2010-9' then year_month = '2010-09';
		else if year_month = '2010-10' then year_month = '2010-10';
		else if year_month = '2010-11' then year_month = '2010-11';
		else if year_month = '2010-12' then year_month = '2010-12';
		else if year_month = '2011-1' then year_month = '2011-01';
		else if year_month = '2011-2' then year_month = '2011-02';
		else if year_month = '2011-3' then year_month = '2011-03';
		else if year_month = '2011-4' then year_month = '2011-04';
		else if year_month = '2011-5' then year_month = '2011-05';
		else if year_month = '2011-6' then year_month = '2011-06';
		else if year_month = '2011-7' then year_month = '2011-07';
		else if year_month = '2011-8' then year_month = '2011-08';
		else if year_month = '2011-9' then year_month = '2011-09';
		else if year_month = '2011-10' then year_month = '2011-10';
		else if year_month = '2011-11' then year_month = '2011-11';
		else if year_month = '2011-12' then year_month = '2011-12';
		else if year_month = '2012-1' then year_month = '2012-01';
		else if year_month = '2012-2' then year_month = '2012-02';
		else if year_month = '2012-3' then year_month = '2012-03';
		else if year_month = '2012-4' then year_month = '2012-04';
		else if year_month = '2012-5' then year_month = '2012-05';
		else if year_month = '2012-6' then year_month = '2012-06';
		else if year_month = '2012-7' then year_month = '2012-07';
		else if year_month = '2012-8' then year_month = '2012-08';
		else if year_month = '2012-9' then year_month = '2012-09';
		else if year_month = '2012-10' then year_month = '2012-10';
		else if year_month = '2012-11' then year_month = '2012-11';
		else if year_month = '2012-12' then year_month = '2012-12';
		else if year_month = '2013-1' then year_month = '2013-01';
		else if year_month = '2013-2' then year_month = '2013-02';
		else if year_month = '2013-3' then year_month = '2013-03';
		else if year_month = '2013-4' then year_month = '2013-04';
		else if year_month = '2013-5' then year_month = '2013-05';
		else if year_month = '2013-6' then year_month = '2013-06';
		else if year_month = '2013-7' then year_month = '2013-07';
		else if year_month = '2013-8' then year_month = '2013-08';
		else if year_month = '2013-9' then year_month = '2013-09';
		else if year_month = '2013-10' then year_month = '2013-10';
		else if year_month = '2013-11' then year_month = '2013-11';
		else if year_month = '2013-12' then year_month = '2013-12';
		else if year_month = '2014-1' then year_month = '2014-01';
		else if year_month = '2014-2' then year_month = '2014-02';
		else if year_month = '2014-3' then year_month = '2014-03';
		else if year_month = '2014-4' then year_month = '2014-04';
		else if year_month = '2014-5' then year_month = '2014-05';
		else if year_month = '2014-6' then year_month = '2014-06';
		else if year_month = '2014-7' then year_month = '2014-07';
		else if year_month = '2014-8' then year_month = '2014-08';
		else if year_month = '2014-9' then year_month = '2014-09';
		else if year_month = '2014-10' then year_month = '2014-10';
		else if year_month = '2014-11' then year_month = '2014-11';
		else if year_month = '2014-12' then year_month = '2014-12';
%mend yearmonth;	

Slow Boat Construction

by in Feature Articles on

Subject: PC hangs on boot
Priority: High
Details:

When the customer boots the PC on site, it launches to the Windows desktop and hangs. Reboots don't fix it.


Terned Off Validations

by in CodeSOD on

Validating user input is one of those problems that's deceptively simple. The actual validation rules tend to be simple to describe: this field should be at least ten characters long, that field should match this regex, this one should be a number. But applying those rules can get cumbersome, especially when you write it yourself.

It can quickly get as thorny and difficult as date handling.


Hugops

by in Error'd on

Hugops to Feedly who seem to have run into a snag this week.

Feeder Brent N. fretted "Seems feedly's update isn't going well, with only 21 of 3 hours left to go."


Curious Queries about Performance

by in CodeSOD on

Andreas's employer recently upgraded their SQL Server databases to the latest version. During that upgrade, something went wrong, and performance dropped off a cliff. Applications which used to be merely slow to taking hours to query the data they required. Clearly, something was wrong in the upgrade process, but Andreas wasn't a DBA, so that wasn't specifically Andreas's problem. Instead, there were plenty of badly performing blocks of code- maybe now was the time to try and optimize them.

That's where this block of Visual Basic comes from.


Twice, Thrice

by in CodeSOD on

Most (but clearly, not all) programmers have generally mastered the basic for loop. If you really want to separate the wheat from the chaff, ask them to write a for loop that counts by two, or three, or some other arbitrary number.

That's what happened at J Banana's workplace, where they needed to parse in tokens from a config file. They come in key value pairs, so the code needs to count by twos. This was their solution:


Classic WTF: The Contractor

by in Feature Articles on
It's a holiday in the US, so let's celebrate our independence by looking into the life on an independent contractor. Original --Remy

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.

EXPENSES

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.


Characters Remaining

by in CodeSOD on

Tina works for a major European government. During the height pandemic, her team needed to roll out many new sites to support remote, self-service interactions with government agencies.

On one of these sites, they needed to create a contact form. The contact form was one of those that applied a character limit to the message. This character limit meant that the code needed to check the length of the input string, and then compare that against some max characters, and then output the "characters remaining" in an output field.