Comparing MVP and MVC architectural patterns in very simple words

User: Click click …

View: Who’s that? [MVP|MVC]

User: I just clicked on the search button …

View: Ok, hold on a sec … . [MVP|MVC]

( View calling the Presenter|Controller … ) [MVP|MVC]

View: Hey Presenter|Controller, a User has just clicked on the search button, what shall I do? [MVP|MVC]

Presenter|Controller: Hey View, is there any search term on that page? [MVP|MVC]

View: Yes,… here it is … “piano” [MVP|MVC]

Presenter: Thanks View,… meanwhile I’m looking up the search term on the Model, please show him/her a progress bar [MVP|MVC]

( Presenter|Controller is calling the Model … ) [MVP|MVC]

Presenter|Controller: Hey Model, Do you have any match for this search term?: “piano” [MVP|MVC]

Model: Hey Presenter|Controller, let me check … [MVP|MVC]

( Model is making a query to the movie database … ) [MVP|MVC]

( After a while … )

— — — — — — This is where MVP and MVC start to diverge — — — — -— –

Model: I found a list for you, Presenter, here it is in JSON “[{“name”:”Piano Teacher”,”year”:2001},{“name”:”Piano”,”year”:1993}]” [MVP]

Model: There is some result available, Controller. I have created a field variable in my instance and filled it with the result. It’s name is “searchResultsList” [MVC]

(Presenter|Controller thanks Model and gets back to the View) [MVP|MVC]

Presenter: Thanks for waiting View, I found a list of matching results for you and arranged them in a presentable format: [“Piano Teacher 2001”,”Piano 1993″]. Please show it to the user in a vertical list. Also please hide the progress bar now [MVP]

Controller: Thanks for waiting View, I have asked Model about your search query. It says it has found a list of matching results and stored them in a variable named “searchResultsList” inside its instance. You can get it from there. Also please hide the progress bar now [MVC]

View: Thank you very much Presenter [MVP]

View: Thank you “Controller” [MVC] (Now the View is questioning itself: How should I present the results I get from the Model to the user? Should the production year of the movie come first or last…? Should it be in a vertical or horizontal list? …)

In case you’re interested, I have been writing a series of articles dealing with app architectural patterns (MVC, MVP, MVVP, clean architecture, …) accompanied by a Github repo here. Even though the sample is written for android, the underlying principles can be applied to any medium.

Author: Pawan Kumar

Leave a Reply

Close Menu
%d bloggers like this:
Skip to toolbar