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
MainView
and some other sub-controller likeStudentController
,TeacherController
. It Contains some methods likegetStudentView()
,getTeacherView()
which provide viewable components of StudentTAB
, TeacherTAB
toMainView
- Main View: It is the main view which is
JFrame
that containsJTabbedPane
which usesMainController#getXXXView()
to display view in itstabs
. (HereXXX
can be replaced byStudent
,Teacher
or any other viewable component which is provided byMain Controller
- Student Controller: It controls the
StudentView
andStudent
model andStudent model interface
. It initialize theStudent View
and provides this view toMain Controller
which is further provide view toMain View
- Student View: It is a
JPanel
which containsJTable
to display the student information and someJButton
likeadd Student, Edit, delete
etc.- Student: It is Student model class that has
name
,rollNo
etc fields to store student information.- Student Model Interface: It is service layer. It takes a
Student
argument and send/add it toStudent Viewable Model
and store into database usingStudent Database Model
.- Student Viewable data Model: It is a
TableModel
that is used to defineJTable
inStudent View
- Student Database Model: Contains method to store/retrieve student information in/from database
- Teacher Controller: Just like
Student Controller
except it controls the teacher related tasks.- Other Controller: Represents many
Student Controller
like 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 Controller
initialize theMain View
and all thesub-controllers
and start the application.Student Controller
implementsActionListener
and act when there is an event inStudent View
. It is responsible to add, edit, delete student information. It takes information fromStudent View
, wrap inStudent
object and pass it toModel Interface
- Model interface then pass
Student
Object toStudent Database Model
which store/update/delete the data in database. If it is successful, thenModel Interface
updateStudent Viewable data model
which is aTable Model
that 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.