Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply MVC with multiple Windows/Dialogs

I want to develop an application using MVC. The application will have multiple Windows and Dialogs ( > 30 Windows/Dialogs ). Now the Question is: How do i apply MVC in such an application?

MVC-Tutorials usually have only one Window, one Controller and one Model.

Would i rather use one View-package with all Views in it, one Controller-package with all Controllers and one Model-package with all Models?

Or would i use one package for each Window/Dialog and implement many small MVCs?

And the final question: Is MVC the right thing to use with multiple Windows/Dialogs or would another pattern be the better solution? This may depend on what the application and each Window/Dialog does, but if there is a general thing to consider, it would be nice to know :)

Edit: Sorry I forgot, didn't think it is important. Question is about Java/Swing. But may want to switch sometime later to whatever comes to mind. Is it important if I use Swing,SWT,GWT?

like image 440
Martin Weber Avatar asked Mar 29 '13 07:03

Martin Weber


1 Answers

I prefer to create packages, each of them contains model, view, controller, etc. because it is more clearly. In this case you see that your application is created in modular form. If you will create applications and create package for controller, view, etc. you won't see what your application do and it will be difficult to maintaint. But this is my own opinion.

For example I will do it in this way

com.car.door
    controller.DoorController
    entity.DoorEntity
    view.DoorView

com.car.wheel
    controller.WheelController
    entity.WheelEntity
    view.WheelView

com.car.driver
    controller.DriverController
    entity.DriverEntity
    view.DriverView

com.car.road
    controller.RoadController
    entity.RoadEntity
    view.RoadView

This is wrong in my opinion because you can't see what your application do and it's hard to maintain

com.car.controller
    controller.DoorController
    controller.WheelController
    controller.DriverController
    controller.RoadController

com.car.entity
    entity.DoorEntity
    entity.WheelEntity
    entity.DriverEntity
    entity.RoadEntity

com.car.view
    view.DoorView
    view.DriverView
    view.WheelView
    view.RoadView
like image 193
pepuch Avatar answered Nov 07 '22 18:11

pepuch