Software

Applications

Microsoft rang in the new year with a cutesy tweet in C#. Just one problem: The code sucked

When marketing meets coding


Microsoft has ushered in 2022 with an amusing (and now deleted) tweet from its Windows Developer account that answers oh so many questions about the quality of code emitted from Redmond nowadays.

As is so often the case, the code (which looked like it aimed to greet 2022 with a perky "Happy New Year") doesn't appear to have troubled a reviewer before going live. Taking aside the fact that it's going to whinge about it still being 2021 when it isn't, there's also the use of the ToString() method when other properties might well have done the job better. And why the "=="?

Click to enlarge

Still, it's the thought that counts. One should consider oneself fortunate that one's own well-intentioned coding cockups have never plopped out of the social media orifice of a company with a market cap in the trillions.

Memories of having to deal with the frankly barking mad US date format still haunt your correspondent to this very day. And then there were the time zones to worry about...

The tweet attracted the usual barrage of supportive and helpful comments typical of Twitter, including a meme from one of Microsoft's own coding boffins, Scott Hanselman, who later followed up with a useful video he described as "an overly detailed analysis of a bad DateTime comparison in C#."

The video is well worth a watch, not least because it delves into not just the obvious flaws in the code but also other considerations that need to be taken into account when handling dates.

As for the original code... well, at best it'll probably keep insisting it is 2021 aside for one brief second. And let's face it, even that isn't right. As another commenter observed: "Yeah 2021 is wrong. We're still stuck in 2020." ®

Send us news
86 Comments

20% discount offer on Windows 365 expires around same time as Windows 10 support

Can't run Windows 11? Microsoft suggests renting it instead

Microsoft moved the goalposts once. Will Windows 12 bring another shift?

Windows 11's hardware requirements: Sales ploy or security play?

Microsoft facing multibillion legal claim over how it sells software

Stop us if you've heard this one before

The 12 KB that Windows just can't seem to quit

Icons from a more civilized time

Microsoft updates the Windows 11 Start Menu

Plus it is solving the 'I can't find the settings' problem with AI. That's what you wanted, right?

Microsoft pulls MS365 Business Premium from nonprofits

Microsoft giveth and Microsoft taketh away

When Microsoft made the Windows as a Service pivot

Former Microsoft engineer calls the Windows of today 'a tool that's a bit of an adversary'

Delta Air Lines class action cleared for takeoff over CrowdStrike chaos

Judge allows aspects of passenger lawsuit to proceed

Microsoft gets twitchy over talk of Europe's tech independence

Brad Smith commits org to facing off with US govt in court to protect them

Microsoft blows deadline for special Azure for EU hosters

Lawyers prepare to get suited and booted if 'Plan B' to address unfair competition claims is a no show

M365 apps on Windows 10 to get security fixes into 2028

Support for the underlying OS is another story

Microsoft to preload Word minutes after boot

Why optimize code when you can just start running sooner?