Search code examples
gwtmvp

GWT MVP: Same view for different objects?


I thought a lot about Building Large Scale Applications and MVP Part I + II.

Let's say, I have three objects e.g. Companies, Contacts and Furniture.

Let's assume that these three objects can be viewed, edited and added and have relations with each other.

Would I really have

  • CompaniesView.ui.xml, ContactView.ui.xml, FurnitureView.ui.xml
  • CompaniesEdit.ui.xml, ContactEdit.ui.xml, FurnitureEdit.ui.xml
  • CompaniesViewImpl.java, ContactViewImpl.java, FurnitureViewImple.java
  • 3x *View.java
  • 3x Edit*ViewImpl.java
  • 3x Edit*View.java
  • 3x *Presenter
  • Millions of Events
  • 3x *ColumnsDefinitionsFactory
  • 3x CompaniesServiceAsync.java, ContactsServiceAsync.java, FurnitureServiceAsync.java for the RPCs
  • I would have nine tokens in my AppController: "companiesList", "contactList", "furnitureList", 3x "*Add", 3x "*Edit"
  • ...

Am I on the right way? Is it just normal that the application gets bigger at this way?

I could also view the three objects in the same view called ObjectView.ui.xml. I guess that's why generics (<T>) are used in the article?

But then I have fear that I can not realize differences any more given due to my object design e.g. that I have a button ImportContacts but no button ImportCompanies.

How do you recommend I should extend my application?


Solution

  • It depends on the use case, but I would have a view and a Representer for each object, because basically the create/edit/view represent the same data and usually have the same layout, thus they could be made in on view and set some kind of modes.

    But if the use case dictate completely different views layout, in that case you may create three views with tree displays interfaces attached to one Presenter.

    Best Practices for Architecting GWT App 2009

    Best Practices for Architecting GWT App 2010