Frontend engineer. Enthusiast of just-in-time learning and learning by teaching as well as deep work concept. Sharing coding tips & my thoughts on dev work.
I am Software Developer, currently interested in static type languages (TypeScript, Elm, ReScript) mostly in the frontend land, but working actively in Python also. I am available for mentoring.
Everything is a state machine, even isLoading state with setState represents such with two possible states. The problem starts when the model needs more than two states, then bool starts to be a problem. I have few articles about this subject, take this - dev.to/macsikora/boolean-the-good-.... 😉
Frontend engineer. Enthusiast of just-in-time learning and learning by teaching as well as deep work concept. Sharing coding tips & my thoughts on dev work.
Agreed, a state machine in this case would be overkill. Compare time and mental load to
write out some if statements (virtually no mental load)
vs
think about representing the logic as a state machine, draw a state diagram, etc
Not only that but the code would be harder for others to grok than if statements and would make them wonder why it was implemented as a state machine - "I must be missing something"
And if you were a contractor, paid by the hour, using a state machine in this case would look like that you were milking your hours and using your time to experiment or hone your skills
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice tip. And if needed you could implement a state machine.
Thanks! Yes, that's true. But state machine would be work for better more complex status management
Everything is a state machine, even isLoading state with setState represents such with two possible states. The problem starts when the model needs more than two states, then bool starts to be a problem. I have few articles about this subject, take this - dev.to/macsikora/boolean-the-good-.... 😉
thanks! I will check out your articles
Agreed, a state machine in this case would be overkill. Compare time and mental load to
Not only that but the code would be harder for others to grok than if statements and would make them wonder why it was implemented as a state machine - "I must be missing something"
And if you were a contractor, paid by the hour, using a state machine in this case would look like that you were milking your hours and using your time to experiment or hone your skills