Computer
How SEC Mobile Phones Can Signal an Imminent Stock Price Drop
Read more of this story at Slashdot.
Court Clears Researchers of Defamation For Identifying Manipulated Data
Read more of this story at Slashdot.
White House Gets Voluntary Commitments From AI Companies To Curb Deepfake Porn
Read more of this story at Slashdot.
Hasbro CEO Claims All His Friends Use AI For D&D, Signal To Embrace It
Read more of this story at Slashdot.
AMD's New Variable Graphics Memory Lets Laptop Users Reassign Their RAM To Gaming
Read more of this story at Slashdot.
Unhappy Workers May Reduce Global GDP By As Much As 9%, Gallup Estimates
Read more of this story at Slashdot.
Billionaire and Engineer Conduct First Private Spacewalk In SpaceX Mission
Read more of this story at Slashdot.
FDA Approves Apple AirPods As Hearing Aids
Read more of this story at Slashdot.
Music Industry's 1990s Hard Drives Are Dying
Read more of this story at Slashdot.
Microsoft To Revamp Windows Kernel Access for Security Vendors
Read more of this story at Slashdot.
Dumbphones and Fax Machines Are the New Boss Flex
Read more of this story at Slashdot.
OpenAI Releases o1, Its First Model With 'Reasoning' Abilities
Read more of this story at Slashdot.
Ex-Google Exec Said Goal Was To 'Crush' Competition, Trial Evidence Shows
Read more of this story at Slashdot.
Unity is Killing Its Controversial Runtime Fee
Read more of this story at Slashdot.
10 Years After It Was Pulled Offline, Viral Mobile Game Flappy Bird Is Coming Back
Read more of this story at Slashdot.
China's Startup Ecosystem Collapses as New Venture Formations Plunge 98%
Read more of this story at Slashdot.
Microsoft Lays Off Another 650 Staff From Its Video Game Workforce
Read more of this story at Slashdot.
As Quantum Computing Threats Loom, Microsoft Updates Its Core Crypto Library
Read more of this story at Slashdot.
Voyager 1 Team Accomplishes Tricky Thruster Swap
Read more of this story at Slashdot.
CodeSOD: Switching the Order
Let's say you had 6 different labels to display. There are many, many ways to solve this problem. Most of them are fine. Some of them are the dreaded loop-switch anti-pattern.
Julien unfortunately inherited one of those.
for($i=0;$i<=5;$i++) { switch($i) { case 1 : print('<p>Activé</p>'); break; case 0 : print('<p>Désactivé</p>'); break; case 2 : print('<p>En cours d\'inscription</p>'); break; case 3 : print('<p>En cours de désinscription</p>'); break; case 4 : print('<p>Désinscrit</p>'); break; case 5 : default : print('<p>Marqué invalide</p>'); break; } }Indentation in the original.
What's beautiful in this, is that we can see that the order of the fields changed. Originally, it was meant to be "Activé", then "Désactivé". But for whatever reason, that wasn't what needed to be on the page, so they flipped the order… by changing the values in the case statement.
It's that bit there that really made this code special, to me. The out-of-order case is the annoying choice that makes bad code truly awful.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!