|
|
|
|
|
by camwest
5242 days ago
|
|
What is the real cost of getting this "wrong"? For example: Backbone.js is following the MVP pattern, more specifically the passive view variant. The catch is that Backbone.js calls Presenters Views and Views Templates. Should we be encouraging "correctness" here or is it ok that every new MV* framework reinterprets these patterns? |
|
Fast forward to today and the UI can now be decoupled from the back-end technology so it is natural to evaluate whether or not the old patterns apply to new practices. In the old model, event based development and widgets had little advantage, event's where overly complex for a service oriented architecture, where a unit of processing is done and then a response is returned. It made little sense to bring in the indirection of event based programming. Further black boxing UI elements into widgets had little advantage because they could not directly respond to events that happen on the client side, in the old way, if a button was clicked, the server had to be notified and it would require complex routing to get that request back to a discreet widget that would have to be recreated or cached and looked up with every request. MVC with procedural C's where the best pattern available to deal with this reality.
Now jumping back to the present, we are not under the same constraints, code can be delivered to the client, the client can respond to events and the client can request processing and data from the back end. Based on this reality, procedural C's don't make a lot of sense, rather events and widgets become a more discreet solution. Designed well, a UI can actually rid itself of almost all procedural glue code external to widgets, via event routing and syndication. In this new reality there is little need to have a controller that says you do this and then you do this. Rather you can build widgets that say when this happens I will do this and when that happens I will tell everyone about this.
Given the dogmatic view of MVC being a best practice people sometimes try to draw parallels and call what they are doing MVC. A better description of MVC or widgets is separations of concerns which is still valid. You should not have JavaScript in HTML and you should not generate HTML from strings in JavaScript. Rather just like in MVC a widget should have an HTML template that represents the view. Some people call widgets micro-MVC which I suppose is correct, but to my MVC implies a controller orchestration a workflow in which I think we are trying to force definitions to not look like the guy that does not know what he is doing. That being said, I think trying to square peg round hole Event/Widget UI development into a MVC definitions is causing a lot of confusion. I think MVC is a relic of web 1.0 page/post programming. What people are really trying to say when they say MVC on the client, is separation of concerns which is still a very relevant and good practice.