software design patterns
TRANSCRIPT
1
Паттерны проектирования
программного обеспечения
Студент : Наджа Аль КузаиГруппа : 1372(СПбГЭТУ «ЛЭТИ»)
MVC – Model , View , Controller
MVP – Model , View , Presenter
MVVM – Model , View , View Model
2
Software Architecture
Software architecture is a technical blueprint explaining how the system will be structured
• The system architecture describes:– How the system will be decomposed into subsystems (modules),– Responsibilities of each module,– Interaction between the modules,– Platforms and technologies used,
• Each module could also implement a certain architectural model / pattern.
Multi-Tier Architecture
3
DB
ORM
WCF
ASP.NET
HTML
The 3-Tier Architecture• The 3-tier architecture consists of the following
tiers (layers):– Front-end (client layer)• Client software – provides the UI of the system
– Middle tier (business layer)• Server software – provides the core system logic• Implements the business processes / services
– Back-end (data layer)• Manages the data of the system (database / cloud)
4
The 3-Tier Architecture Model
5
Business Logic
DesktopClient
MobileClient
ClientMachine
network
network
network Database
Data Tier(Back-End)
Middle Tier(Business Tier)
Client Tier (Front-End)
Typical Layers of the Middle Tier• The middle tier usually has parts related to the
front-end, business logic and back-end:
6
Presentation LogicImplements the UI of the application (HTML5, Silverlight, WPF, …)
Business LogicImplements the core processes / services of the application
Data Access LogicImplements the data access functionality (usually ORM framework)
7
MVC (Model-View-Controller)
What is MVC and How It Works?
8
Model-View-Controller (MVC)
• MVC is one of three ASP.NET programming models.• MVC. Presented by Trygve Reenskaug in 1979
9
Model-View-Controller (MVC)
Model–view–controller (MVC) is a software design pattern (architectural pattern) for implementing user interfaces . It divides a software application into three interconnected parts, – Separates the business logic from application data and presentation:
• Model– Keeps the application state (data)
• View– Displays the data to the user (shows UI) , visible layer
• Controller– Handles the interaction with the user , manages Views & user interaction
10
MVC- Environment
• .NET– ASP.NET MVC, MonoRail
• Java– JavaServer Faces (JSF), Struts, Spring Web MVC, Tapestry,
JBoss Seam, Swing• PHP– CakePHP, Symfony, Zend, Joomla, Yii, Mojavi
• Python– Django, Zope Application Server, TurboGears
• Ruby on Rails
11
MVC
MySQL/ NoSQL/MongoDB
PHP / Rubby / Paython
Linux / Windows Server
HTML, Java Script/ CSS
Browser/firefox/Internet explorer
Client
Contains all storage
Controller
12
MVC-Based Frameworks
MODEL:Adding & receiving items from DBProcessing Data from/to DBSpeaking only with controllerVIEW:Only this that user sees.Speaking only with controllerCONTROLLER:Takes info from user.Processes info & talks to DB if needed.Receives info from DB.Speaks to VIEW to explain presentation.
13
Model-View-Presenter (MVP)
14
MVP (Model-View-Presenter)• Model-View-Presenter (MVP) is UI design pattern
similar to MVC– Model
• Keeps application data (state)– View
• Presentation – displays the UI and handles UI events (keyboard, mouse, etc.)
– Presenter• Presentation logic (prepares data taken from the model to be
displayed in certain format)
15
MVVM Model-View-ViewModel
• Model-View-ViewModel (MVVM) is architectural pattern for modern UI development Invented by Microsoft for use in WPF and SilverlightBased on MVC, MVP and Martin Fowler's Presentation
Model patternOfficially published in the Prism project (Composite
Application Guidance for WPF and Silverlight) Separates the "view layer" (state and behavior) from the
rest of the application
16
MVVM Structure
• Model– Keeps the application data / state representation– E.g. data access layer or ORM framework
• View– UI elements of the application– Windows, forms, controls, fields, buttons, etc.
• ViewModel– Data binder and converter that changes the Model
information into View information– Exposes commands for binding in the Views.
17
MVVM Structure
MVVM is typically used in XAML applications (WPF, Silverlight, WP7) and supports unit testing.
18
Comparison MVC - Model View Controller • The input is directed at the Controller first.• Many-to-one relationship between the Controller and the View. • One-to-one relationship from Controller to View. • The Controller returns back to the Model, so there is knowledge between the View and the
expected Model being passed into it. MVP – Model View Presenter• The input begins with the View, not the Presenter.• There is a one-to-one relationship between the View and the Presenter.• The View holds a reference to the Presenter which is aware of the View its associated with.• The Presenter updates the View based on the requested actions it performs on the Model, but
the View is not Model aware. MVVM – Model View View Model• The input begins with the View, not the View Model.• While the View holds a reference to the View Model, the View Model has no information
about the View. • One-to-many relationship between multiple Views and one View Model.• For example, a WPF View and a Silverlight View could share the same View Model.
19
Вопросы
20
Спасибо за внимание