'Women are not safe anywhere': Inside 'rape fantasy' chat rooms where men expose footage of family members - even their own sisters or mothers - to equally perverted strangers
Section of A130 has two lanes closed due to earlier crash
Section of A130 has two lanes closed due to earlier crash
Carlos Alcaraz brushed aside the queues and boos brought by Donald Trump to claim the US Open crown with impeccable brilliance, writes MATTHEW LAMBWELL
Who's who in Trump's US Open box? President is flanked by beaming granddaughter Arabella and MAGA inner circle
Trump gets intriguing crowd reaction as he appears with family and staff at US Open... but TV viewers are BANNED from seeing it
MTV VMAs 2025 WINNERS: Ariana Grande shocks as she earns top honor while Lady Gaga upsets Taylor Swift
People left furious by 'awful' mistake on dentist's floor that you 'can't unsee' - but, can YOU spot it?
Children in tears as school imposes 'prison-like regime' including bathroom ban, kids forced to stand in the rain by 'drill sergeant' and stripped-down menu with only 10 minutes to eat
Controversial £25m 'Nanny State' national emergency alert flops on live TV as BBC reporter's alarm fails and thousands report their phones were either late or never went off
STEPHEN GLOVER: Mahmood is impressive. But she's fighting with both her hands tied behind her back
Labour civil war to replace Rayner: New nightmare for Starmer as party's left try to take control and hammer his 'mistakes' - as Emily Thornberry throws her hat into ring for deputy leader
Ariana Grande makes FOUR wardrobe changes at VMAs... and gives shout-out to her 'therapist and gay people'
Revealed: Britain's favourite foreign cuisine... and it's NOT Indian
Kate Moss' £35k doggy bag! Model uses her pricey Birkin to pick up her pet's poop as she enjoys a stroll with pal Sarah Nimmo in Mayfair
Firefighters rush to huge blaze at bungalow in Hadleigh
Harry embarks on 'pseudo royal' tour - but Palace is silent over whether four-day visit will include seeing his father
VMAs 2025 best dressed! Sabrina Carpenter, Tate McRae and Ashlee Simpson flash the flesh in VERY revealing gowns at MTV bash
CodeSOD: Pretty Little State Machine
State machines are a powerful way to organize code. They are, after all, one of the fundamental models of computation. That's pretty good. A well designed state machine can make a complicated problem clear, and easy to understand.
Chris, on the other hand, found this one.
static { sM.put(tk(NONE, NONE, invite), sp(PENDING, INVITED)); // t1 sM.put(tk(REJECTED, REJECTED, invite), sp(PENDING, INVITED)); // t2 sM.put(tk(PENDING, IGNORED, invite), sp(PENDING, INVITED)); // t3 sM.put(tk(PENDING, INVITED, cancel), sp(NONE, NONE)); // t4 sM.put(tk(PENDING, IGNORED, cancel), sp(NONE, NONE)); // t5 sM.put(tk(PENDING, BLOCKED, cancel), sp(NONE, BLOCKED)); // t6 sM.put(tk(INVITED, PENDING, accept), sp(ACCEPTED, ACCEPTED)); // t7 sM.put(tk(INVITED, PENDING, reject), sp(REJECTED, REJECTED)); // t8 sM.put(tk(INVITED, PENDING, ignore), sp(IGNORED, PENDING)); // t9 sM.put(tk(INVITED, PENDING, block), sp(BLOCKED, PENDING)); // t10 sM.put(tk(ACCEPTED, ACCEPTED, remove), sp(NONE, NONE)); // t11 sM.put(tk(REJECTED, REJECTED, remove), sp(NONE, NONE)); // t12 sM.put(tk(IGNORED, PENDING, remove), sp(NONE, NONE)); // t13 sM.put(tk(PENDING, IGNORED, remove), sp(NONE, NONE)); // t14 sM.put(tk(BLOCKED, PENDING, remove), sp(NONE, NONE)); // t15 sM.put(tk(PENDING, BLOCKED, remove), sp(NONE, BLOCKED)); // t16 sM.put(tk(NONE, BLOCKED, invite), sp(PENDING, BLOCKED)); // t17 sM.put(tk(IGNORED, PENDING, invite), sp(PENDING, INVITED)); // t19 sM.put(tk(INVITED, PENDING, invite), sp(ACCEPTED, ACCEPTED)); // t20 sM.put(tk(NONE, NONE, remove), sp(NONE, NONE)); // t21 sM.put(tk(NONE, BLOCKED, remove), sp(NONE, BLOCKED)); // t22 sM.put(tk(BLOCKED, NONE, remove), sp(NONE, NONE)); // t23 }Honestly, I only know this is a state machine because Chris told me. I could hazard a guess base on the variable name sM. The comments certainly don't help. Numbering lines isn't exactly what I want comments for. I don't know what tk or sp are actually doing.
So yes, this is an unreadable blob that I don't understand, which is always bad. But do you know what elevates this one step above that? If you note the third parameter to the tk function- invite, cancel, accept, etc? Those are constants. So are INVITED, PENDING, ACCEPTED.
While I am not fond of using the structure of a variable name to denote its role, "caps means const" is a very well accepted standard. A standard that they're using sometimes, but not all the time, and just looking at this makes me grind my teeth.
.comment { border: none; }