Why are people hysterically afraid of maybe having to type a few characters more? BOILERPLATE!!!1
All of the arguments for having named constants are sound, especially if you are developing with a good IDE. I don't need to type the named constants imports, the IDE autocompletes and auto-formats them for me. It can follow usage across my project, renaming constants is a lot easier, I can just go into my constant definition, rename the constant and it will be changed everywhere, somewhat safe, whereas the string replacement is just that: brittle string replacement. ("Oopps.. that name was also a sub-name in that? unfortunate..)
He miuses Cargo Cult Programming for this architectural pattern. Cargo Cult is when you do stuff that you apply magic value to without being able to explain how it works. As I said before: There are valid reasons for this, just because you choose to ignore them doesn't make it Cargo Cult.
More often than not, the best solution is the simplest one.
Or it produces brittle scripty-hacky programs that need to be completely rewritten next year.
edit: If you're code-golfing your silly TODO app examples, go ahead. Personally I wouldn't be using redux if I didn't need it to write maintainable applications of non-trivial complexity.
Also agree here and honestly couldn't the problems he describes very easily fixed by ES6 classes with static constants? That way you would not need all those silly imports and keep the constants to their specific regions like import EventConstants from './EventConstants.' case EventConstants.loadRequest case EventConstants.addFailure etc etc
18
u/fforw May 15 '17
Why are people hysterically afraid of maybe having to type a few characters more? BOILERPLATE!!!1
All of the arguments for having named constants are sound, especially if you are developing with a good IDE. I don't need to type the named constants imports, the IDE autocompletes and auto-formats them for me. It can follow usage across my project, renaming constants is a lot easier, I can just go into my constant definition, rename the constant and it will be changed everywhere, somewhat safe, whereas the string replacement is just that: brittle string replacement. ("Oopps.. that name was also a sub-name in that? unfortunate..)
He miuses Cargo Cult Programming for this architectural pattern. Cargo Cult is when you do stuff that you apply magic value to without being able to explain how it works. As I said before: There are valid reasons for this, just because you choose to ignore them doesn't make it Cargo Cult.
Or it produces brittle scripty-hacky programs that need to be completely rewritten next year.
edit: If you're code-golfing your silly TODO app examples, go ahead. Personally I wouldn't be using redux if I didn't need it to write maintainable applications of non-trivial complexity.