Re:Flags Are a Code Smell (2014)
by merlincorey on Sunday May 22, 2022 @03:47AM
(#31465889)
> The article's most interesting point is that the vast majority of possible program (or object) states tend to be invalid. For example, `Person(isWalking=true, isAlive=false)` is nonsense, because there's an unexpressed constraint that `isWalking==true ==> isAlive==true`.
Are you implying that Undead aren't people?
Also, magical Undead states aside, I'm pretty sure it is possible for a Person to be Walking while they are not technically Alive if something else is able to control their motor system as happens in nature with various Wasps, Slime Balls, and more.
You make good points. Some of these "illegal" states may be legal from some other perspective, or yet-unforeseen use cases.
Re:Flags Are a Code Smell (2014)
by gentleman11 on Sunday May 22, 2022 @12:54PM
(#31470244)
Bug or feature?
Re:Flags Are a Code Smell (2014)
by aastronaut on Sunday May 22, 2022 @03:26AM
(#31465775)
Also a great talk from Richard Feldman about "Making Impossible States Impossible": https://www.youtube.com/watch?v=IcgmSRJHu_8
Though the author veers in another direction, I think his core point is related to this discussion:
Applying “make invalid states unrepresentable” https://news.ycombinator.com/item?id=24685772