0% found this document useful (0 votes)
35 views13 pages

SoftwareArchitecture MVC SeminarReport

Uploaded by

cuong.ta14584
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views13 pages

SoftwareArchitecture MVC SeminarReport

Uploaded by

cuong.ta14584
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

HOA SEN UNIVERSITY

FACULTY OF INFORMATION - TECHNOLOGY

Instructor : Mr. Pham Hong Thanh

Students : Ma Chan Hien

Lam Chi Khang

Trinh Anh Cuong

Nguyen Ngoc Quoc

Nguyen Tuan Anh

Class : Software Architecture_1433_2331

August / 2023
HOA SEN UNIVERSITY

FACULTY OF INFORMATION - TECHNOLOGY

Instructor : Mr. Pham Hong Thanh

Students : Ma Chan Hien

Lam Chi Khang

Trinh Anh Cuong

Nguyen Ngoc Quoc

Nguyen Tuan Anh

Class : Software Architecture_1433_2331

August / 2023
2
TABLE OF CONTENTS

ABSTRACTION ................................................................................................................ 4
CONTENT ......................................................................................................................... 5
1. Definition: ................................................................................................................... 5
2. Operating Mechanism (Flow: View - Controller - Model): ................................... 5
3. Advantages and Disadvantages: ............................................................................... 6
3.1 Advantages ............................................................................................................ 7
3.2 Disadvantages ........................................................................................................ 7
4. Applications: ............................................................................................................... 7
5. Conclusion: ................................................................................................................. 8
6. Demo:........................................................................................................................... 8
7. MVC Architecture Use Cases ................................................................................. 11
7.1 Web Development: .............................................................................................. 11
7.2 Other Domains: ................................................................................................... 11
7.3 Conclusion: .......................................................................................................... 12
REFERENCES ................................................................................................................ 13

3
ABSTRACTION

This report is written by team H’s members to describe clearly about our Seminar project
– MVC Architecture. This work consists of 5 people in total: Ma Chan Hien, Trinh Anh
Cuong, Nguyen Ngoc Quoc, Nguyen Tuan Anh and Lam Chi Khang.

We will briefly describe what is MVC, and how actually MVC work (the MVC flow),
also we will provide its pros and cons. Our aim is to elucidate the fundamental concepts
of MVC, elucidate its operational flow, outline its advantages and drawbacks, and
culminate with a practical demonstration. Last but not least, we will have a small demo
in the end of the seminar to show clearer what we spoke.

4
CONTENT

1. Definition:
MVC, or Model-View-Controller, is a fundamental software architectural pattern widely
employed in various applications, from websites to software systems. It delineates the
application into three integral components, each serving distinct functions while remaining
independent of one another. Notable frameworks supporting MVC include ASP.NET
MVC, Laravel, and Angular. The forthcoming presentation will delve into the core
principles that underpin MVC and illuminate how these components coalesce to drive
functionality.

2. Operating Mechanism (Flow: View - Controller - Model):

Figure 1: General Flow Chart of MVC Architectures in Web Browser

5
The MVC architecture revolves around three key components:
View: Serving as the user interface, encompassing elements like text, buttons, and images.
Users interact with the application through this interface.
Controller: An intermediary component that retrieves user input from the View and
communicates it to the Model. It facilitates seamless interaction between the View and the
Model.
Model: The logic component where data processing occurs. It handles program logic,
interacts with databases (if applicable), and transmits processed data back to the Controller,
subsequently displayed via the View.
The collaboration and interdependence of these components are pivotal for the proper
functioning of the application.

Figure 2:General Flow Chart of MVC Architectures

3. Advantages and Disadvantages:


The distinct separation of the Model, View, and Controller components within MVC yields
several advantages & disadvantages:

6
3.1 Advantages

 Reduced Interdependence: Enhances maintenance, upgrades, and changes without


affecting other components.
 Parallel Development: Allows simultaneous development of components,
expediting the process.
 Ease of Debugging: Facilitates easier identification and rectification of issues.
 Modularity: Easier maintenance and updates.
 Scalability: Can handle growing and changing requirements.
 Reusability: Components can be reused in different contexts.
 Testability: Facilitates unit testing for improved software quality.

3.2 Disadvantages

 Learning Curve: Requires a comprehensive understanding for smooth operation.


 Documentation Challenges: May lack comprehensive documentation.
 Higher Development Costs: Simultaneous development of three components can
escalate costs.

4. Applications:
MVC is widely used in various software applications, including:
 Web Development: Popular in frameworks like ASP.NET MVC, Ruby on Rails,
and Django.
 Desktop Applications: Used in GUI applications to separate presentation from
business logic.
 Mobile Applications: Adopted in mobile app development for clean architecture.
Also the MVC's versatility allows its implementation across various domains, including
IoT, AI, gaming, web development, and applications. Web and app domains, in particular,
heavily utilize MVC due to robust support from frameworks and languages, streamlining
project management, maintenance, and development processes.

7
5. Conclusion:
The MVC architecture divides applications into three core components - Model, View, and
Controller. Each has its strengths and weaknesses, and the choice of the most suitable
model for a specific application is paramount. Considering application needs and
characteristics is crucial in selecting an appropriate model. Additionally, exploring other
architectural patterns like MVVM, MVP, MPI, etc., can provide further insights into
optimizing software designs.

6. Demo:
Simple Login Demo in C#
Summary:
This demonstration illustrates a basic login system using the Model-View-Controller
(MVC) pattern in C#. The application comprises three main components:
LoginModel: Manages user data (username and password).
LoginView: Handles user interface interactions and displays messages.
LoginController: Acts as an intermediary, retrieves user input, validates login credentials,
and communicates between the Model and View.
Components:
LoginModel.cs
public class LoginModel {
private String userName;
private String password;

public LoginModel() {

}
public LoginModel(String userName, String password){
this.userName = userName;
this.password = password;
}

public String getUserName() {


return userName;
8
}

public void setUserName(String userName){


this.userName = userName;
}

public String getPassword(){


return password;
}

public void setPassword(String password) {


this.password = password;
}
}

LoginController.cs
using System.Data.SqlClient;

public class LoginController {


private LoginVIew view;
public LoginController(LoginVIew view) {
this.view = view;
}

public void login() {


while(true){
LoginModel user = view.GetUserInfo();
if (checkLogin(user)) {
view.showMessage("Success!");
break;
} else {
view.showMessage("Wrong username or password!");
}
}
}

private bool checkLogin(LoginModel user){


if (user.getUserName().Equals("admin")) { //Check if the data is exist in the database
return true;
}
return false;
}

9
public LoginVIew getView(){
return view;
}

public void setView(LoginVIew view) {


this.view = view;
}
}

LoginView.cs
public class LoginVIew {
public void showMessage(String msg){
Console.WriteLine(msg);
}

public LoginModel GetUserInfo(){


LoginModel user = new LoginModel();
Console.WriteLine("Username: ");
user.setUserName(Console.ReadLine());
Console.WriteLine("Password: ");
user.setPassword(Console.ReadLine());
return user;
}
}

Program.cs
public class Program {
public static void Main(String[] args){
LoginVIew view = new LoginVIew();
LoginController control = new LoginController(view);
control.login();
control.getView();
}
}

10
7. MVC Architecture Use Cases
7.1 Web Development:

E-commerce Platforms: Building shopping websites where MVC separates product data
(Model), user interface (View), and transaction processing (Controller).
Social Media Platforms: Implementing MVC to handle user profiles (Model), the display
of content and user interactions (View), and managing user actions (Controller).
Content Management Systems (CMS): Utilizing MVC to manage content (Model),
present it in various formats (View), and handle user interactions for content creation and
editing (Controller).
Mobile Applications:
Native App Development: Employing MVC to organize data handling (Model), UI
elements and user interactions (View), and user inputs and app logic (Controller).
Hybrid App Development: Utilizing frameworks like Ionic or Xamarin, where MVC helps
segregate backend data operations (Model), frontend UI rendering (View), and user
interaction logic (Controller).
Desktop Applications:
Business Management Software: Creating applications where MVC isolates the business
logic and data management (Model), the visual representation of data (View), and user
actions and input handling (Controller).
Media Players: Utilizing MVC to separate playlist management and media library
(Model), graphical display of media and controls (View), and user actions like play, pause,
stop (Controller).

7.2 Other Domains:

Game Development: Implementing MVC to organize game data (Model), render graphics
and animations (View), and handle user inputs and game mechanics (Controller).

11
IoT Applications: Employing MVC to segregate data collection and management
(Model), device connectivity and status display (View), and user or system interactions
(Controller).

7.3 Conclusion:

MVC architecture's versatility and modular structure make it applicable across a wide
spectrum of software development, providing flexibility, scalability, and maintainability
across various domains and platforms.

12
REFERENCES

1. 8 Real-World Examples of Using the MVC Design Pattern


2. Mô Hình MVC trong JAVA là gì? VÍ DỤ cụ thể Của Mô Hình MVC
3. MVC Framework - Introduction
4. MVC Design Pattern - GeeksforGeeks
5. Mô hình MVC
6. Tìm hiểu mô hình MVC dành cho người mới bắt đầu: Cấu trúc và ví dụ ...
7. Tất tần tật về mô hình MVC
8. Tổng quan về mô hình MVC

13

You might also like