CodeSOD: Dating in Another Language
It takes a lot of time and effort to build a code base that exceeds 100kloc. Rome wasn't built in a day; it just burned down in one.
Liza was working in a Python shop. They had a mildly successful product that ran on Linux. The sales team wanted better sales software to help them out, and instead of buying something off the shelf, they hired a C# developer to make something entirely custom.
Within a few months, that developer had produced a codebase of 320kloc I say "produced" and not "wrote" because who knows how much of it was copy/pasted, stolen from Stack Overflow, or otherwise not the developer's own work.
You have to wonder, how do you get such a large codebase so quickly?
private String getDatum() { DateTime datum = new DateTime(); datum = DateTime.Now; return datum.ToShortDateString(); } public int getTag() { int tag; DateTime datum = new DateTime(); datum = DateTime.Today; tag = datum.Day; return tag; } private int getMonat() { int monat; DateTime datum = new DateTime(); datum = DateTime.Today; monat = datum.Month; return monat; } private int getJahr() { int monat; DateTime datum = new DateTime(); datum = DateTime.Today; monat = datum.Year; return monat; } private int getStunde() { int monat; DateTime datum = new DateTime(); datum = DateTime.Now; monat = datum.Hour; return monat; } private int getMinute() { int monat; DateTime datum = new DateTime(); datum = DateTime.Now; monat = datum.Minute; return monat; }Instead of our traditional "bad date handling code" which eschews the built-in libraries, this just wraps the built in libraries with a less useful set of wrappers. Each of these could be replaced with some version of DateTime.Now.Minute.
You'll notice that most of the methods are private, but one is public. That seems strange, doesn't it? Well this set of methods was pulled from one random class which implements them in the codebase, but many classes have these methods copy/pasted in. At some point, the developer realized that duplicating that much code was a bad idea, and started marking them as public, so that you could just call them as needed. Note, said developer never learned to use the keyword static, so you end up calling the method on whatever random instance of whatever random class you happen to have handy. The idea of putting it into a common base class, or dedicated date-time utility class never occurred to the developer, but I guess that's because they were already part of a dedicated date-time utility class.
Boeing offloads some software businesses to private equiteer Thoma Bravo
Beleaguered aerospace giant Boeing has sold some of its “Digital Aviation Solutions” portfolio to private equity outfit Thoma Bravo.…
Pope Francis' death sparks massive spike in Conclave streaming numbers as viewers seek answers over selection of next pope
Shop Zara, Beatrice and Eugenie's exact Bahrain Grand Prix outfits - including must-have ME+EM dress now 50% off
Tearful Angellica Bell FINALLY breaks silence on Martin Lewis axe on Celebrity Big Brother before brutal eviction
Police 'concerned' after cat found dead with horrific injuries in housing estate
Ben Affleck drops biggest hint yet about why marriage to Jennifer Lopez failed even though he 'adores' her
Malcolm In The Middle cast seen in first photo for reboot hours after star Frankie Muniz says he hit 'new low'
Rupert Murdoch's 'wild child' granddaughter Charlotte Freud passionately kisses new boyfriend in corset and suspenders following marriage breakdown
The hardest primary schools to get into in Essex
Asia reaches 50 percent IPv6 capability and leads the world in user numbers
Asia has become the second region in the world to reach 50 percent IPv6 capability, according to data from labs run by the Asia Pacific Network Information Center (APNIC).…
The Pope's final resting place: Chipboard barrier hides niche where Francis will be buried, four miles from the Vatican, in accordance with his wishes
Hitman who killed Maurizio Gucci shoots his son in the face then turns the pistol on himself
Kids to sing with family fun at VE-Day community party in Great Notley
Locations across Essex to feature on popular BBC Two railway show
Exact date Lakeside Shopping Centre inflatable obstacle course on water will open this summer
Reese Witherspoon's thinly-veiled snarky jab at Blake Lively over nude photos resurfaces in new viral video
Yahoo Will Give Millions To a Settlement Fund For Chinese Dissidents
Read more of this story at Slashdot.