how to organization our code?

i have been studing flux lately,i have been thinking the diffrence between flux and mvc,so facebook think mvc has a few drawbanks,that is the complex relationship between model and view,i have been thinking what is mvc?i think the Truly mvc should not have this releshionship like facebook saild,i think view notice controller,controller notice model,then model`s change is captured by view,a view a controller,a controller many model, a model many view,so we find it,many model with many view,but between many model and many view is controller,controller control model`s change,but controller can not change model,it can only change model by model`s method,so i think facebook`s model is just a dictionnary,and the Method of Modifying Model is not in model,and the model`s change is in controller,soThat's the problem,flux think it has Unidirectional data flow,view -> action -> store -> view,so if you use mvc correctly,you will have Unidirectional data flow too, view -> controller -> model`s method -> model -> view, but in single page.i think we should use flux,first Let's think about it,what is controller`s duty,respondd to view`s demands and change model, and skip view,now we use router ti skip view, if we change model in view,so we don`t need controller?because Business Logic is in model,and Application Logic is in view and router,so we know why we need flux finally,but i think flux just a beautiful model,model`s methos is action,model`s data is store,view monitoring model and if view want change it can change model by model`s methods. 

猜你喜欢

转载自www.cnblogs.com/mrzhu/p/11070765.html