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.

About the Author

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.

comments powered by Disqus

Featured

  • Microsoft Eases Integration with Semantic Kernel AI SDK

    The basic idea is to provide unified API abstractions, especially for idiomatic C# code, to help platform developers and others work with any provider with standard implementations for caching, telemetry, tool calling and other common tasks.

  • Final .NET 9 Preview Ships with Go-Live License

    Visual Studio developers can now download the SDK for .NET 9 Release Candidate 2 with a go-live license, meaning devs get Microsoft support for production applications even before the framework reaches general availability next month.

  • Upcycle Your Old Laptops into a Kubernetes Cluster

    Learn about Windows-to-Linux conversions and how to break and fix cloud containers -- all while helping to save the world from e-waste with some "sheer geeky fun."

  • Visual Studio's Future: Live Help to 'AI-ify Your App'

    Visual Studio guru Mads Kristensen provided a peek into the IDE's AI future, explaining how while in live-coding it will identify opportunities for your own app to use AI to your advantage.

Subscribe on YouTube