News for hackers. Stuff that matters.
Re:Show HN: Build your first real world React.js application by dandelany on Wednesday September 07, 2016 @06:01PM (#12448255)
I'm not sure why everyone is getting hung up on the fact that this is implemented with strings and a switch statement. Who cares? Use constants. If JS had enums we would use them, but it doesn't.

The point is that there are a finite, well-enumerated set of possible state changes, which are all localized in one place: the reducer. Whether you call them "DO_THING" vs. constants.actions.DO_THING (which could be an integer or whatever you want) or whether you use a switch statement vs. if block vs. dictionary lookup is entirely up to you.

Re:Show HN: Build your first real world React.js application by sotojuan on Wednesday September 07, 2016 @07:04PM (#12448768)
I'm not sure why but a lot of developers think or are taught that switch statements are old fashioned or even bad.
Re:Show HN: Build your first real world React.js application by ramchip on Wednesday September 07, 2016 @07:40PM (#12448963)
Probably because programmers new to OO tend to use them when inheritance/interfaces would be cleaner (case cat, case dog, etc.)