Cheapest petrol and diesel in Essex as fuel hits four-year high
Jesy Nelson 'dating landscape gardener ex of TOWIE star Lydia Bright' as she shares teasing photo of her new man
Prime Suspect writer Lynda La Plante breaks down in tears as she becomes the latest victim of the 20mph tyranny and is handed driving ban that will 'end her career'
Spain Offers $1.14 Billion To Get Thirty Meter Telescope Moved To Canary Islands
Read more of this story at Slashdot.
I was drinking more than ten bottles of wine and a litre of spirits a week. I used so many tricks to make sure my baby wasn't impacted... nobody had a clue. But during a family game of Monopoly, my shame came tumbling out
Trump REJECTS Iran's 'duplicitous' claims that peace talks aren't happening... after desperate leaked email shows his war chiefs in panic mode
Reform and Restore at odds over a deal: Parties' leaders swap insults as Farage says he won't agree to call to ditch Tory defectors
Peter thought his sudden breathlessness and itchy arms was a heart attack. In fact, he has a life-threatening allergy caused by EXERCISE. Running for the bus could be fatal. Here are the vital warning signs to watch for
'Sexually motivated' Greek NHS doctor who smirked as he showed junior colleague explicit video on his phone is suspended for 'abusing his senior position'
Britain's richest WhatsApp group: How some of the UK's biggest National Lottery winners have a community sharing holiday snaps and discussing how to spend their money
Thylane Blondeau shares the making of her Miu Miu wedding dress as she reveals the custom lace gown took 240 hours to make
Joe Wicks quits the Cotswolds after selling his £3.25million mansion: Fitness guru is latest star to abandon A-list rural hotspot
NASA puts astronauts’ lives in the hands of Tesla’s flaky Cybertruck
Breast screening misses 95 per cent of young women who go on to develop cancer, study suggests
CodeSOD: Always Take the Option
Frequent submitter Capybara James sends us this simple snippet, which highlights that even when you have the lovely convenience of Optional types, you can use them wrong.
if (StringUtils.hasLength(dto.getAssetModelUUID()) // Other conditions ) { return Optional.ofNullable(dto); }We access the getAssetModelUUID member of dto, and if it's a non-empty string, we can then return a nullable of this thing that's definitely not null in the first place.
Okay, in the scheme of things, that's not that bad. All we're really doing is just not using the syntactic sugar that automatically boxes your dto into a nullable type. On it's own, it's not bad, just ugly. But like all things, it doesn't exist on its own. It exists inside of a giant pile of code where this pattern is used all the time. Even functions which don't return nullable types box (and unbox) the type. Optional is scattered through the code like a magic ward against null reference exceptions.
Does it help? No, not really, the code is buggy and error prone. Will it ever get fixed? Probably not in this lifetime.