I'm developing a software project in java swing. I want to follow MVC design pattern for better maintainability, portability and reliability. I've looked upon MVC in Swing on internet and found some good results like THIS
, THIS , THIS, THIS, THIS and few more (youtube too) and studied them. Then I built a design architecture for my project based on MVC design pattern. Here is the structure which simulate my actual requirements:
Here is little description about the architecture
- Main Controller: It is responsible to initialize and to start the application. It initialize
MainViewand some other sub-controller likeStudentController,TeacherController. It Contains some methods likegetStudentView(),getTeacherView()which provide viewable components of StudentTAB, TeacherTABtoMainView- Main View: It is the main view which is
JFramethat containsJTabbedPanewhich usesMainController#getXXXView()to display view in itstabs. (HereXXXcan be replaced byStudent,Teacheror any other viewable component which is provided byMain Controller- Student Controller: It controls the
StudentViewandStudentmodel andStudent model interface. It initialize theStudent Viewand provides this view toMain Controllerwhich is further provide view toMain View- Student View: It is a
JPanelwhich containsJTableto display the student information and someJButtonlikeadd Student, Edit, deleteetc.- Student: It is Student model class that has
name,rollNoetc fields to store student information.- Student Model Interface: It is service layer. It takes a
Studentargument and send/add it toStudent Viewable Modeland store into database usingStudent Database Model.- Student Viewable data Model: It is a
TableModelthat is used to defineJTableinStudent View- Student Database Model: Contains method to store/retrieve student information in/from database
- Teacher Controller: Just like
Student Controllerexcept it controls the teacher related tasks.- Other Controller: Represents many
Student Controllerlike controllers
NOTE Teacher Controller and other controllers have same hierarchy as that of Student Controller. These controllers access their models and view. For e.g. Teacher Controller have Teacher View, Teacher and Teacher Model Interface
Working of the project
Firstly
Main Controllerinitialize theMain Viewand all thesub-controllersand start the application.Student ControllerimplementsActionListenerand act when there is an event inStudent View. It is responsible to add, edit, delete student information. It takes information fromStudent View, wrap inStudentobject and pass it toModel Interface- Model interface then pass
StudentObject toStudent Database Modelwhich store/update/delete the data in database. If it is successful, thenModel InterfaceupdateStudent Viewable data modelwhich is aTable Modelthat reflects changes inStudent View
So my question is whether it is a good design for this kind of application and if it is not, then what should do I do. How can I refine the design for better maintainability, reliability portability. What are some recommendations
I think its a straight and rigid question but I can't do better.
