Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Related Rants
In javascript, is there a difference between separate function calls that mimic a "chain pattern" or state changes using if/else if/else and using the chain or state pattern directly? The internet gave me no real/helpful response to that.
Suppose that:
if(isThingA(thing)) {
makeThingB();
else if(isThingB(thing)){
makeThingC();
else {
makeThingA();
}
That code is always executed e.g. after a user mouse click. "thing" gets defined in some other code.
It can be seen as a state machine that goes back to its starting point.
Is a pattern with objects/classes/prototypes even needed/preferred instead?
It's partly a problem I'm facing in my code but it's also interesting to know ideas/thoughts on this.
question
functions
javascript
kiss vs pattern
conditions
chain/state pattern