SDA - Lab 7 - 2k21 - Part1-1
SDA - Lab 7 - 2k21 - Part1-1
Laboratory # 07
UET TAXILA
Engr. Sidra Shafi
Tool: Eclipse
Introduction:
The Model View Controller (MVC) design pattern specifies that an application consist of a data
model, presentation information, and control information. The pattern requires that each of these
be separated into different objects.
MVC is more of an architectural pattern, but not for complete application. MVC mostly relates
to the UI / interaction layer of an application. You are still going to need business logic layer,
and data access layer.
Separation of concerns: view and controller depend on model, but model depends on neither.
A fundamental design pattern for the separation of user interface logic from business logic.
StudentView.java
StudentController.java
Output:
Advantages of MVC:
• Multiple developers can work simultaneously on the model, controller, and views.
• MVC enables logical grouping of related actions on a controller together. The views
for a specific model are also grouped together.
• Models can have multiple views.
• Make the code more organized and standard.
• Avoid Complexity.
• Enable easy debugging.
Suppose an organization wants to manage the record of its employees. Each Employee has
an id, name and job. Create appropriate methods to set these values in model. Employee
Model also has a paraemeterized constructor. The Controller recieves Employee obj and
View Obj and set the appropriate values and then call the PrintEmployeeInformation
method of View Class. In main method of MVCDemo class, call the paremeterized
contructor of employee class, and then create view and pass these two objects in controller
object. Use controller to display view. Change some values and then display view again, You
can also call updateview in each setter method of controller or call explicitly in main method.
Expected Output:
***************