MVC for Javascript (tl;dr)

There's a great in depth article on developing MVC apps in Javascript here: http://peter.michaux.ca/articles/mvc-architecture-for-javascript-applications

It's something I've been thinking a lot about lately and was excited to find someone had written about it. The article is short sweet and to the point, but for the tl;dr generation I'll summarize it here:

  1. model: (a) All data sits in model. (b) Fires events when data changes. [server-side communication happens here. knows nothing about DOM.]
  2. view: (a) Listens to model events. (b) Calls handlers in controller. [all DOM interaction happens here. don't use ids, so that views can be reusable within same page.  knows nothing about state/logic.]
  3. controller: (a) Decides how to respond to user interaction. (b) Modifies the model. [abstract logic]

No comments:

Post a Comment