DevDisasters

### Developer Fail: Epoch Billing System

Everybody in the IT department was quite happy -- even a little surprised -- with how well the outsourced project to replace the legacy billing system was progressing.

Well, actually, the project managers weren't all that surprised. Over the past four months, they'd pumped out reams of specs and design documents, often boasting that their level of planning hadn't been seen since the Apollo missions. So, for them, the fact that everything was turning out as designed spoke volumes about the success of their planning and processes.

New Billing Code
Jeff and the other developers who were stuck supporting the existing billing system until the big cutover (still a few months away) wanted to see what this super system looked like under the hood. After all, because they were expected to support the new system once it came online, shouldn't they at least have an understanding of how the underlying code worked?

The developers made their case for months before the project managers gave up on their "it's not done yet" rhetoric and reluctantly handed over a few modules that they'd deemed bug-free.

When Jeff got his hands on the code, one line in particular caught his eye:

int strElapsedDays = (convertDate(intDay1,
intMonth1, intYr1) - convertDate(intDay2,
intMonth2, intYr2)) / DAY;

Unusual Process
Knowing that C# had built-in functions to easily determine the span of days between two dates, Jeff thought the approach was a little strange. Once he tracked down convertDate, things got even weirder:

public const int DAY = 86400;
public const int WEEK = 604800;
public const int YEAR = 31449600;

private static int convertDate
(int day, int month, int year)
{

int[] months = new int[] {0,31,59,90,120,151,
181,212,243,273,304,334};

return (((year - 1970) * DAY * 365) + (((year
- 1970)/4) * DAY) + (months[month - 1]
* DAY) + ((day-1) * DAY));
}

Caught off guard, Jeff just stared at the function for a good 10 minutes, trying to figure it out. When he did, it hit him like a ton of bricks. Rather than using the built-in C# date functions, the developer had opted to convert a date into its Unix Epoch -- the number of seconds elapsed since Jan. 1, 1970 -- and work from there.

Jeff had to admit, the solution was a little bit genius. Unfortunately, it wasn't a fit because the new system was running on a Windows server. So Jeff did his duty and raised the matter with the project management team so it could be added to the bug-fix queue for the offshore team.

Weeks later, Jeff followed up with one of the members of the project management team, just out of curiosity, to see if the fix had been made. To his surprise, it hadn't been addressed -- nor would it be any time soon. Apparently the "bug" was downgraded to a feature request because -- in the eyes of the project managers -- if an application functioned as it was designed, there wasn't a need to go back in and change it.

Mark Bowytz is a contributor to the popular Web site The Daily WTF. He has more than a decade of IT experience and is currently a systems analyst for PPG Industries.

• ### Lessons Learned Building a GenAI-Powered App

Sometimes, complex technical achievements are best explained through one example. That's the approach Mete Atamel, Developer Advocate at Google, is taking as he makes the rounds detailing the capabilities of Vertex AI and associated tooling on the Google Cloud Platform.

• ### 30th Annual Visual Studio Magazine Reader's Choice Awards Announced

For the 30th year in a row, Visual Studio Magazine readers have chosen the best tools and services for developers. The 2024 winners are honored in 43 categories, from component suites to testing tools to AI helpers.

• ### Another Report Weighs In on GitHub Copilot Dev Productivity: ðŸ‘Ž

Several reports have answered "yes" to the question of whether GitHub Copilot improves developer productivity. A new one says "no."

• ### Logistic Regression with Batch SGD Training and Weight Decay Using C#

Dr. James McCaffrey from Microsoft Research presents a complete end-to-end program that explains how to perform binary classification (predicting a variable with two possible discrete values) using logistic regression, where the prediction model is trained using batch stochastic gradient descent with weight decay.