DC braces for massive turning point in Trump's takeover as protesters take the streets shouting 'Go home, fascists'
Woman, 28, reveals how pregnancy hormones made her face completely unrecognisable and 'like an old person'
The Fat Pizza with a 'secret dough recipe' opens in Brentwood shopping centre
Putin prepares for nuclear war on eve of Trump summit: Russia readys new cruise missile nuke for tests in satellite images after Donald warned of 'severe consequences' if Ukraine conflict continues
Heatwave reveals 'ghost' buildings at historic properties: Parch marks of long lost hall and buried wall show up in grounds of abbey and manor house
'Is prowling for catcallers really the best use of police time?' Fury as undercover cops pose as joggers to catch wolf-whistlers
Loose Women star Nadia Sawalha, 60, opens up about her 'horrendous' health battle in a heartbreaking video
CodeSOD: An Array of Parameters
Andreas found this in a rather large, rather ugly production code base.
private static void LogView(object o) { try { ArrayList al = (ArrayList)o; int pageId = (int)al[0]; int userId = (int)al[1]; // ... snipped: Executing a stored procedure that stores the values in the database } catch (Exception) { } }This function accepts an object of any type, except no, it doesn't, it expect that object to be an ArrayList. It then assumes the array list will then store values in a specific order. Note that they're not using a generic ArrayList here, nor could they- it (potentially) needs to hold a mix of types.
What they've done here is replace a parameter list with an ArrayList, giving up compile time type checking for surprising runtime exceptions. And why?
"Well," the culprit explained when Andreas asked about this, "the underlying database may change. And then the function would need to take different parameters. But that could break existing code, so this allows us to add parameters without ever having to change existing code."
"Have you heard of optional arguments?" Andreas asked.
"No, all of our arguments are required. We'll just default the ones that the caller doesn't supply."
And yes, this particular pattern shows up all through the code base. It's "more flexible this way."
.comment { border: none; }Mark Wright left 'disappointed' after holiday with baby daughter Palma
Back to being FOSS, Redis delivers a new, faster version
Redis 8.2 is FOSS again, albeit under a different license, and has multiple performance enhancements. Meanwhile, Redis 7.2, the last of the old FOSS versions, is nearing its end of life. New version, or new Valkey?…
Sha'Carri Richardson hurls vile insult at boyfriend in explosive new video of arrest for domestic violence
Should Princesses Eugenie and Beatrice take on more royal duties? Have your say in the Palace Confidential poll
'Comrade Princess': Which 'appallingly behaved' Royal won over a Communist dictator with her drunken antics?
Kylie Jenner bares cleavage in racy look as she indulges in girls' night amid Timothee Chalamet split rumors
Inside Princess Beatrice and Princess Eugenie's designer wardrobes as their style evolution continues
Desktop-as-a-service now often cheaper to run than laptops - even after thin client costs
Analyst firm Gartner has declared hosted PCs are now often cheaper to operate than on-prem laptops, and two years away from being cost-effective for 95 percent of workers.…