Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC vs. Flux ? Bidirectional vs. Unidirectional?

Looking at the following diagram (which explains MVC), I see unidirectional data flow.

So why do we consider MVC to have bidirectional data flow while justifying Flux ?

MVC Pattern

like image 386
Arian Avatar asked Oct 31 '15 03:10

Arian


People also ask

Is MVC bidirectional?

MVC-type implementation enforces bidirectional data flows, which differs from the unidirectional data flow maintained in Flux and Redux. In MVC, there is no single direction in an application that data flows in.

What is bidirectional and unidirectional data flow?

Bidirectional and unidirectional dataflow refers to boundaries, domains, and direction data moves between services and views. Binding refers to a singular one-one-one relationship, while bidirection and unidirection refers to the relationship between components.

Is MVP unidirectional?

Unidirectional. There's a bi-directional data flow between View and Presenter in MVP. To set the data to the view, it usually calls view. setUser(user) and to update certain data, view would call presenter.


1 Answers

Real and Pure MVC is unidirectional. It is clear from the the wikipedia diagram pasted in the question.

More than a decade ago, when server side frameworks like Apache Struts implemented a variant of MVC called Model View Presenter (MVP) pattern, they made every request go through controller and every response come back through controller. Everyone continued calling it MVC. Due to inherent nature of the web, any changes in the model cannot be propagated to the view without view sending a request or update. So Pure MVC is not implemented. Rather MVP is implemented.

Few years back, when frameworks like Angular, Ember, Knockout implemented MVC on front end, they implemented another variant of MVC called Model View ViewModel (MVVM) pattern, few folks continued called it MVC. (and few realized that terminology is not important and called it MVW (W stands for Whatever)), none of them implemented pure MVC.

When React was born, they took the opportunity to implement pure MVC (not MVP or MVVM), and renamed it as Flux with few changes. I feel Flux is one more variant of MVC. Although, Flux/React team says it is not MVC, I see lot of parity between both the architectures - Flux and MVC.

like image 70
Arun Kandregula Avatar answered Nov 09 '22 03:11

Arun Kandregula