this post was submitted on 14 Aug 2025
294 points (96.2% liked)

Programmer Humor

25730 readers
1229 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] dohpaz42@lemmy.world 71 points 1 day ago (19 children)

I mean aside of the variable name, this is not entirely unreasonable.

[–] shape_warrior_t@programming.dev 29 points 1 day ago (4 children)

I would certainly rather see this than {isAdmin: bool; isLoggedIn: bool}. With boolean | null, at least illegal states are unrepresentable... even if the legal states are represented in an... interesting way.

[–] nialv7@lemmy.world 2 points 17 hours ago (1 children)

Admin false LoggedIn false doesn't feel illegal to me, more redundant if anything

[–] shape_warrior_t@programming.dev 5 points 16 hours ago* (last edited 16 hours ago) (2 children)

I was thinking of the three legal states as:

  • not logged in (null or {isAdmin: false, isLoggedIn: false})
  • logged in as non-admin (false or {isAdmin: false, isLoggedIn: true})
  • logged in as admin (true or {isAdmin: true, isLoggedIn: true})

which leaves {isAdmin: true, isLoggedIn: false} as an invalid, nonsensical state. (How would you know the user's an admin if they're not logged in?) Of course, in a different context, all four states could potentially be distinctly meaningful.

[–] nialv7@lemmy.world 2 points 13 hours ago

ah you are right! i am so dumb.

[–] chocrates@piefed.world 1 points 12 hours ago

Honestly logged in is state and shouldn't be on the user object.

load more comments (2 replies)
load more comments (16 replies)