Conor McGregor civil rape case appeal begins as judges consider claims Nikita Hand was 'beaten by her partner hours after the alleged sex attack'
Paramedic's brain tumour was missed five times by doctors who blamed her symptoms on a 'lazy eye'
The little-known pill that saved my life after unimaginable grief caused my drinking to spiral out of control
DRAM spot prices doubled last week
Spot prices for DRAM have doubled in the last week.…
Essex grandad among 60 people suing cruise company after 'nightmare' holidays
Essex grandad among 60 people suing cruise company after 'nightmare' holidays
Essex weather updates: highs of 33C expected today
I've started throwing a cup of cold water over my husband every time he keeps to his lazy bathroom habits - I've been called 'bitter' but I'm tired of his excuses
A lot of product makers snub Right to Repair laws
A year after the Right to Repair laws passed in California and Minnesota, many product makers still aren't doing much to help consumers fix the gear they bought.…
'Space Is Hard. There Is No Excuse For Pretending It's Easy'
Read more of this story at Slashdot.
Expert issues major warning to users of period tracker apps
Vet issues urgent warning over social media trend - saying it could KILL your dog
Khloe Kardashian finally sets the record straight on EVERY cosmetic surgery she's ever had done
After 123 years, the royal train hits the buffers: First ridden by King Edward VII, Charles deems running costs 'unjustifiable'
Husband of British woman killed in Spanish jet ski horror describes how he swam out to 'hold her in my arms until she passed away' after she was struck by boat driven by a friend
Liam Payne given heartbreaking tribute at the start of new Netflix series Building The Band which was filmed before his tragic death
Proton bashes Apple and joins antitrust suit that seeks to throw the App Store wide open
Secure comms biz Proton has joined a lawsuit that alleges Apple’s anticompetitive ways are harming developers, consumers, and privacy.…
CodeSOD: It's Not Wrong to Say We're Equal
Aaron was debugging some C# code, and while this wasn't the source of the bug, it annoyed him enough to send it to us.
protected override int DoCompare(Item item1, Item item2) { try { DateTime thisDate = ((DateField)item1.Fields["Create Date"]).DateTime; DateTime thatDate = ((DateField)item2.Fields["Create Date"]).DateTime; return thatDate.CompareTo(thisDate); } catch (Exception) { return 0; // Sorry, ran out of budget! } }Not to be the pedantic code reviewer, but the name of this function is terrible. Also, DoCompare clearly should be static, but this is just pedantry.
Now, there's a lot of implied WTFs hidden in the Item class. They're tracking fields in a dictionary, or maybe a ResultSet, but I don't think it's a ResultSet because they're converting it to a DateField object, which I believe to be a custom type. I don't know what all is in that class, but the whole thing looks like a mess and I suspect that there are huge WTFs under that.
But we're not here to look at implied WTFs. We're here to talk about that exception handler.
It's one of those "swallow every error" exception handlers, which is always a "good" start, and it's the extra helpful kind, which returns a value that is likely incorrect and provides no indication that anything failed.
Now, I suspect it's impossible for anything to have failed- as stated, this seems to be some custom objects and I don't think anything is actively talking to a database in this function (but I don't know that!) so the exception handler likely never triggers.
But hoo boy, does the comment tell us a lot about the codebase. "Sorry, ran out of budget!". Bugs are inevitable, but this is arguably the worst way to end up with a bug in your code: because you simply ran out of money and decided to leave it broken. And ironically, I suspect the code would be less broken if you just let the exception propagate up- if nothing else, you'd know that something failed, instead of incorrectly thinking two dates were the same.
.comment { border: none; }