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

Post-CrowdStrike catastrophe, Microsoft figures moving antivirus out of Windows kernel mode is a good idea

Existing low-level access for security solutions will undergo a rework

Windows 11 continues slog up the Windows 10 mountain

Almost three years on and many customers have yet to make the move

Windows 11 users still living in the past face forced update, like it or not

22H2 and 21H2 holdouts about to be dragged to 23H2

Microsoft decides it's a good time for bad UI to die

Set the Control Panel for the heart of the Sun

Copilot for Microsoft 365 might boost productivity if you survive the compliance minefield

Loads of governance issues to worry about, and the chance it might spout utter garbage

We know 'Linux is a cancer' but could CentOS chaos spell opportunity for Microsoft?

Analyst suggests Redmond's internal distro may one day fly the coop

If every PC is going to be an AI PC, they better be as good at all the things trad PCs can do

Microsoft's Copilot+ machines suck at one of computing's oldest use cases

Major ISP bungles settings, causing Microsoft 365, Azure outage

AT&T confirms 'brief disruption,' no indication of foul play

Ex-Windows boss who tried to save the Start Menu now Shopify tech wizard

Time to make e-commerce great again instead?

About that Windows Installer 'make me admin' security hole. Here's how it's exploited

What kind of OS can be hijacked by clicking a link at just the right time? Microsoft's

Microsoft exec warns of business functions being sacrificed on the altar of AI

Too many IT modernization projects? Not enough budget? Something will have to give

Microsoft's Inflection acquihire is too small to matter, say UK regulators

Deal can't lessen competition if AI minnow wasn't much of a competitor