software design patterns

20
Паттерны проектирования программного обеспечения Студент : Наджа Аль Кузаи Группа : 1372 (СПбГЭТУ «ЛЭТИ») VC – Model , View , Controller VP – Model , View , Presenter MVVM – Model , View , View Model 1

Upload: alkuzaee

Post on 15-Apr-2017

92 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Software Design Patterns

1

Паттерны проектирования

программного обеспечения

Студент : Наджа Аль КузаиГруппа : 1372(СПбГЭТУ «ЛЭТИ»)

MVC – Model , View , Controller

MVP – Model , View , Presenter

MVVM – Model , View , View Model

Page 2: Software Design Patterns

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.

Page 3: Software Design Patterns

Multi-Tier Architecture

3

DB

ORM

WCF

ASP.NET

HTML

Page 4: Software Design Patterns

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

Page 5: Software Design Patterns

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)

Page 6: Software Design Patterns

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)

Page 7: Software Design Patterns

7

MVC (Model-View-Controller)

What is MVC and How It Works?

Page 8: Software Design Patterns

8

Model-View-Controller (MVC)

• MVC is one of three ASP.NET programming models.• MVC. Presented by Trygve Reenskaug in 1979

Page 9: Software Design Patterns

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

Page 10: Software Design Patterns

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

Page 11: Software Design Patterns

11

MVC

MySQL/ NoSQL/MongoDB

PHP / Rubby / Paython

Linux / Windows Server

HTML, Java Script/ CSS

Browser/firefox/Internet explorer

Client

Contains all storage

Controller

Page 12: Software Design Patterns

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.

Page 13: Software Design Patterns

13

Model-View-Presenter (MVP)

Page 14: Software Design Patterns

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)

Page 15: Software Design Patterns

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

Page 16: Software Design Patterns

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.

Page 17: Software Design Patterns

17

MVVM Structure

MVVM is typically used in XAML applications (WPF, Silverlight, WP7) and supports unit testing.

Page 18: Software Design Patterns

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.

Page 19: Software Design Patterns

19

Вопросы

Page 20: Software Design Patterns

20

Спасибо за внимание