Monday, March 20, 2017

Angular Design Patterns

Some basic differences of the different AngularJS Design Patterns can be written in short:
MVC (Model View Controller):
Traditional MVC is where there is a
  1. Model: Acts as the model for data
  2. View : Deals with the view to the user which can be the UI
  3. Controller: Controls the interaction between Model and View, where view calls the controller to update model. View can call multiple controllers if needed.
MVP(Model View Presenter):
Similar to traditional MVC but Controller is replaced by Presenter. But the Presenter, unlike Controller is responsible for changing the view as well. The view usually does not call the presenter.
MVVM (Model View View Model)
The difference here is the presence of View Model. It is kind of an implementation of Observer Design Pattern, where changes in the model is represented in the view as well, by the VM. Eg: If a slider is changed, not only the model is updated but the data which may be a text, that is displayed in the view is updated as well. So there is a two way data binding.
Will shortly update the article with more details and code examples...

No comments:

Post a Comment