26 August 2012

14 steps to create MVP application

In this article we will see what the basic steps we should follow for creating any MVP application.

  1. Create a project structure with 4 folders
Model,View,Presenter and ViewInterfaces.

  1. Create Entities in Model to represent data.

  1. Create DataAccessLayer for interacting with database.

  1. Create BusinessAccessLayer.

  1. Identify the Display, Focus and Binding functionalities to be done in the UI,

  1. Create interfaces (View Interface) and put those methods inside it.

  1. Create Presenter class with a private global variable of type ViewInterface.

  1. Create a constructor for Presenter class accepting a parameter of type of ViewInterface and inside constructor, assign parameter value to global parameter created in the step 7.

  1. Identify actions to be performed in the UI like [Binding the Grid], [Save the record if validation passes].

  1. Put all those methods inside Presenter (As these methods are action methods, all will be with return type void.)

  1. Create View and implement View interface and override all the methods.

  1. Create a global private Presenter object inside a View.

  1. Create default constructor for view and inside it initialize presenter object created in step 12, passing current Page instance as parameter.

  1. Handle events in the view and pass control to Presenter

In 3-Tier application in UI, we handle the events and call the actions (methods in short) defined in the page itself and In MVP in UI, we handle the events and call the actions defined in the presenter.

Hope you enjoyed,
Refer following links to learn more about MVP and 3-Tier architecture.

Hope to see some good comments.

No comments:

Post a Comment


Things are upgraded
