Saturday, February 3, 2018

React and Redux

What is the difference?

One I hadn't wanted to attempt as thorough researcher to answer this question with technical ins and outs, but rather approach this with a simplest possible answer, at least a reduced answer that avoids all the technical ins and outs of differences here.

One while react does provide in its framework controller model and controller logic interfacing, by far, React provides a framework with the design aspect of encapsulating mvc structure in a component by component basis and View predominant in its focus.  While React can be designed functional in nature, it seems to me to lend itself to classical OOP design patterns.  It is, of course, also quite easy to learn and trending popular in terms of adoption and use.

Redux apps on the other hand may share some structural difference to MVC design patterns in the way of separating Controller and Model logic with the that of the view systems, as opposed to having a compact all in one strictly component integration.  That is, in housing model and controller logic to the component.  Redux logic separate Controller logic into, for instance, actions and states of the app, and making ease in generalizing the state and actions of the application across components and containers, which are components that merely handle the delegation of component actions and states.  It is also one of a functional design pattern that provides injection patterns into component and containers alike, so it also extends functional design in a positive way given flexibility and power in evolving state and action of the app.  The downside (if such is appropriate) is that Redux has a higher learning curve for adoption, at least in the pure sense of learning redux without middleware helpers.

Which to use?

If you were wanting to gain experience with Redux design and especially functional programming work, it seems Redux would be a good choice.

If you have complex state and action managements for you Web Apps design patterns, Redux may also be  another good choice, though as I've read for asynchronous management, you may need some added middle ware helper (Redux provides advice on this).

If you are new to creating Web Apps or want something that easy to dive into, React is great as a learning tool and creating a web app quickly.   React provides great versatility and state management is especially easy to understand and implement.  However, complex state management systems with two way bindings and especially implementing a generalized state management system could be also just as cumbersome work in React relative to Redux.  Thus I've seen, for instance, WebRTC web apps designed in Redux relative to being purely React, and there's likely no coincidence where app states and actions would need be shared across a number of components since an overarching controller system provides some clarity to the approach of binding data.  Redux, add goes beyond what Angular provides here especially where Angular component models increasingly resemble the simplicity of React's components which has been the trend apparently for any number of web app frameworks.
 While two way bindings, for instance, attend to the problem of two way state mutations, in React or Angular for that matter, on the other, hand I've found myself violating the mutability principle of functional programming design.  That is, instead of mutating the inputs, providing a return object that expresses a new state.  Redux, in this way, could be considered the preferable approach if and wherever app design patterns make use of two way bindings between child and parent components and is required.

If you know neither, perhaps, it may help to understand React first and then learn Redux.  Though when learning Redux provides for enough distinction to think of Redux app by way of Redux design through its native api documentation (React may not be helpful) alone.  Trying to understand Redux, through React documentation, in other words, can get in the way, in my opinion.

React is to Redux, however, arguably for what Python is to C++...which is something to keep in mind. 

No comments:

Post a Comment

Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...