DEV Community

when-you-look-at-the-sky
when-you-look-at-the-sky

Posted on

Beauty of Encapsulation, but in Redux, everything is global and we shout

I thought programming was becoming really beautiful: local variables, encapsulation first into a structure, and then we have Object-oriented programming, so we encapsulate both the values and the methods into a structure, and it was really beautiful.

And then now we have Redux, where everything is global. Everybody can read it if they want to, but to prevent anybody from modifying it, we "SHOUT". Just like my coworkers, "Shout out to Peter", "Shout out to Susan". Now they "Shout out to global variables (state). Change it this way and that way."

I actually did some JavaScript framework where everything was an object, and we communicate to the object through methods, the usual way... and it worked quite well.

But... a big pool of global variables, a lot of shouting. Tons of selectors, tons of reducers, tons of middleware or other libraries, saga, rematch, etc, etc. Let's see where this is going. In 20 or 100 years, I wonder if people'd say, "our software engineering has improved a lot. It all started with a big pool of global variables and a lot of shouting."

Top comments (0)