An MVP guide to JavaScript – The benefits

Nearing the end of 2009 I switched jobs to a new location, where I was tasked with building a new web application. The weapons of choice was Google’s, very new to the time, GWT 2.0.

This was my first exposure to Google’s Java-Compiled-JavaScript, and I was hesitant.

Google Web Toolkit (GWT/ˈɡwɪt/) is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java.

GWT emphasizes reusable, efficient solutions to recurring Ajax challenges, namely asynchronous remote procedure calls, history management, bookmarkinginternationalization and cross-browser portability.

Wikipedia – GWT

In my two years work with GWT I can say that these are the pros and cons with the platform:

  • Very manageable code, hierarchical and modular
  • Splitting the code to Widgets produces highly reusable code
  • MVP design for web apps is perfect in the way that the UI is just as important as the code behind it
  • Medium-high overhead, requires time to get used to and work fast
  • Can become a source of over engineering
  • Some are frustrated by the amount of files per functionality


While I really loved working with GWT, it was obvious that it will not be a part of the future, as JavaScript is getting the attention it deserves and for the most part, there really is no reason to stick with Java to write JavaScript (besides some compilation benefits).

I think it’s time to harvest the benefits from GWT and implements those in pure JavaScript.

What I wanted to do is to take the modular, MVP approach to web applications, the data model and persistency, and create a basic guidelines to implements those features in JavaScript.

I was asked to elaborate on the difference between MVP architecture and current MVC and MVVM JS frameworks.
I played with Backbone.js, Knockout.js, Ember.js and Angular.js. While some of those frameworks are more robust than the others, none of them support true separation between the presenter logic and the UI logic.
The aforementioned frameworks either rely on ‘stupid’ UI templates, where no logic can be inserted, or they mix UI and app logic heavily.
The MVP architecture I’m describing provides full decoupling between the UI and the app’s logic.

More info on those frameworks and others can be found in Gordon’s excellent blog post:
The Top 10 Javascript MVC Frameworks Reviewed

In the next post I will got through my implementation of MVP and explain the reasoning for it, you can take it as is, just the parts that you like, or completely reject it (but if you do, please comment why).

An MVP guide to JavaScript – Model-View-Presenter

  1. googlepo said:

    Thank you very much for that astonishing article

Leave a Reply to googlepo Cancel reply

Your email address will not be published. Required fields are marked *