6 ms·
I think the "React.js way" through a Flux flow takes this idea even farther. Now, instead of an individual object being allowed to change itself, we go through
by asolove 11y ago
I think the "React.js way" through a Flux flow takes this idea even farther. Now, instead of an individual object being allowed to change itself, we go through an even greater indirection, firing an abstract action and letting a store figure out how to make changes to the appropriate data.
The real question is: if our data has real validation and invariants, who maintains them?
- Does every piece of code that might change one attribute have to worry about it?
- Do individual objects protect themselves through methods and take responsibility?
- Or does a whole managed context take responsibility, allowing it to guarantee invariants about groups of objects together?
Experience tells us the first option quickly becomes problematic. The second certainly works, but requires discipline in how you design objects (the origin of many of the DDD patterns). The third is less widely used, seems to work better, but has some overhead. But don't kid yourself that it's less indirection/metaprogramming. It's more.
- dustingetz 11y agoGreat post, I'm gonna take this off topic now because I've been thinking a lot about this and curious your thought: > we go through an even greater indirection, firing an abstract action and letting a store figure out how to make changes to the appropriate data Can't this indirection just be modeled as a function? Instead of firing an action we call a function, which returns the appropriate state updates. No metaprogramming, and composable when used with cursor pattern to run the actual state update effect. (ActionStoreDispatcher flux doesn't compose)
- asolove 11y agoYeah! (You probably know about this but others may not.) I like Elm's architecture, which has typed update functions that can be nested. This makes the full stack of the component composable and is something like a cursor: https://gist.github.com/evancz/2b2ba366cae1887fe621 https://gist.github.com/evancz/2b2ba366cae1887fe621