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

Microsoft to kill off third-party printer drivers in Windows

Go native or go home: End of servicing plan rolled out for legacy printer drivers in fresh update

Microsoft Surface chief Panos Panay abruptly announces departure

Rumors point to Panay headed to Amazon to take over for outgoing Alexa and Echo chief David Limp

Google exec: Microsoft Teams concession 'too little, too late'

If you don't tackle Redmond's abuse of software licensing in rival clouds it'll be game over for innovation, warns Amit Zavery

Beneath Microsoft's Surface event, AI spreads everywhere

Windows gets its own Copilot to help operate the operating system – Edge, Bing, Outlook, 365 not spared, either

Get ready to say hello to new Windows and goodbye to an old friend

The clock is ticking for Windows troubleshooters, plus Microsoft's preparing a new OS release

Microsoft Edge still forcing itself on users in Europe

Promised change to allow Windows system links open in the actual default browser not yet evident

Microsoft calls time on ancient TLS in Windows, breaking own stuff in the process

Hold onto your SQL Server, enterprise admins

Microsoft worker accidentally exposes 38TB of sensitive data in GitHub blunder

Included secrets, private keys, passwords, 30,000+ internal Teams messages

CMA says new Microsoft-Activision deal addresses concerns

Meet gaming's power couple, with Ubisoft the third wheel. Now competition watchdog must ensure Windows biz keeps promises

Windows File Explorer gets nostalgic speed boost thanks to one weird bug

A glitch that makes the lives of users better? Where do we sign?

Europe wants easy default browser selection screens. Mozilla is already sounding the alarm on dirty tricks

Can you blame it?

Microsoft’s AI investments skyrocketed in 2022 – and so did its water consumption

In its rush to lead the generative ML world, Redmond may have developed a datacenter drinking problem