SlideShare une entreprise Scribd logo
LE PATTERN VIEW MODEL AVEC
SYMFONY2
QUI SUIS-JE ?
Romain Kuzniak
@TurnItUpMethod
Responsable Technique chez OpenClassrooms
1 M de membres, 2,7 M de VU / 25-30 M de pages vues
Design applicatif, musique et Symfony2
Designs applicatifs avec Symfony2
DE QUOI EST-IL QUESTION ?
ViewControllerDomain
ViewControllerModel
MVC
Presentation
Layered
ViewController
Business
Layer
Data
Layer
Presentation
Infrastructure
Domain Driven Design
Domain
Layer
Application
Layer
ViewController
Presentation
ViewController
Entity
Clean Architecture
Use Case
Gateway
Implementations
Boundary
Presentation
Vue Controller
Data
WTF Design
Kitten
Layer
Unicorns
Park
CONTROLLER
VIEW
SIMPLE, MAIS …
Le post suivant
La liste des derniers posts vus
La liste des posts les + vus
Une recommandation de posts
…
QUELS SONT LES PROBLÈMES ?
APTITUDE AU CHANGEMENT
La présentation dépend du domaine
Un changement entraîne des changements dans
toutes les couches
Too much knowledge
LOGIQUE DANS LA VUE
Pour gérer des cas métiers
Pour gérer des variables non-définies
Pour gérer des valeurs par défaut
LOGIQUE DANS LA VUE
Pour gérer des cas métiers
Pour gérer des variables définies
Pour gérer des valeurs par défaut
COMPLEXITÉ DANS LE CONTROLLER
Un espace trop important est occupé pour le
passage des paramètres à la vue
COMPLEXITÉ DANS LE CONTROLLER
Un espace trop important est occupé pour le
passage des paramètres à la vue
UTILISATION DES COMPOSANTS
La visibilité des variables n’est pas claire (entre
le template et celui dans lequel il est inclus)
Les composants ne sont pas facilement
réutilisables
TESTABILITÉ
Les tests nécessitent les couches du domaine
LE PATTERN VIEW MODEL
Plusieurs variations : Model View ViewModel,
Model View Presenter, Presentation Model,
MVC …
Objectif : Créer une abstraction entre les
objets du domaine et la présentation
View
Model
Objet du
domaine
Objet du
domaine
Assembler
LE MODEL
Représentation de la vue
Objet sans logique (DTO)
LE MODEL
L’ASSEMBLER
Data mapper
L’ASSEMBLER
LE CONTROLLER
LA VUE
AVANTAGES
APTITUDE AU CHANGEMENT
Le domaine et la vue peuvent évoluer en toute
indépendance
La vue ne possède que les données utiles
LOGIQUE DANS LA VUE
La logique peut être déportée dans le View
Model, l’assembler ou un service dédié
COMPLEXITÉ DANS LE CONTROLLER
La création des données pour la vue est
déportée dans l’assembler
UTILISATION DES COMPOSANTS
A un composant correspond un View Model
La logique de construction est factorisée
Un seul paramètre à passer au template
TESTABILITÉ
La création de stub est simple
Le front et le back ont la possibilité de travailler
en parallèle
INCONVÉNIENTS
Plus de classes
-totokiller38
«Avec les frameworks MVC javascript, utiliser des
vues dans une application c’est so 2009.»
-BoomBoomStriker
« Cette présentation est nulle, moi j’utilise des APIs. »
API
Une api est une représentation de ressources
ViewControllerDomain
ResourceControllerDomain
API MODEL
API CONTROLLER
Ou utilisez votre serializer favori
EN BREF
EN BREF
Créer une abstraction représentant la vue ou la ressource
Domaine et présentation varient indépendamment
La vue ne possède aucune logique
Les composants sont facilement identifiables
Testable
S’adapte totalement avec Twig
S’adapte totalement avec une api
BIBLIOGRAPHIE
Martin Fowler - Patterns of Enterprise
Application Architecture - Éditions Addison-
Wesley - 2004
Derek Greer - Interactive Application
Architecture Patterns
MSDN
MERCI

Contenu connexe

PDF
MySQL enterprise backup overview
PDF
Hadoop Hbase - Introduction
PPTX
Exploring game industry from an Egyptian perspective
PDF
PPTX
RDBMS to NoSQL. An overview.
PDF
Architectures de virtualisation
PDF
Introducing Clean Architecture
PDF
Clean architecture with ddd layering in php
MySQL enterprise backup overview
Hadoop Hbase - Introduction
Exploring game industry from an Egyptian perspective
RDBMS to NoSQL. An overview.
Architectures de virtualisation
Introducing Clean Architecture
Clean architecture with ddd layering in php

Tendances (20)

PDF
Chapitre 2 hadoop
PPTX
Cohesion et couplage
PDF
Test Automation - Principles and Practices
PPT
PRESENTATION PROJET TuniBourse
PDF
Implementer ITIL
PPTX
Introduction aux web services
PPTX
Azure Storage Services - Part 01
PDF
Nodejs - A performance que eu sempre quis ter
PDF
MySQL Database Architectures - High Availability and Disaster Recovery Solution
PDF
Rapport exposé eXtreme Programming XP
PPTX
Vertical Slicing Architectures
PPTX
Supervision V2 ppt
PDF
Understanding Azure Networking Services
PDF
Uml upxp2
PDF
Resume de BI
PPTX
AUTOMATION FRAMEWORK USING SELENIUM & TESTNG ALONG WITH MAVEN
PPTX
Présentation cloud computing
PDF
Saturn 2018: Managing data consistency in a microservice architecture using S...
PDF
Mise en oeuvre des framework de machines et deep learning v1
Chapitre 2 hadoop
Cohesion et couplage
Test Automation - Principles and Practices
PRESENTATION PROJET TuniBourse
Implementer ITIL
Introduction aux web services
Azure Storage Services - Part 01
Nodejs - A performance que eu sempre quis ter
MySQL Database Architectures - High Availability and Disaster Recovery Solution
Rapport exposé eXtreme Programming XP
Vertical Slicing Architectures
Supervision V2 ppt
Understanding Azure Networking Services
Uml upxp2
Resume de BI
AUTOMATION FRAMEWORK USING SELENIUM & TESTNG ALONG WITH MAVEN
Présentation cloud computing
Saturn 2018: Managing data consistency in a microservice architecture using S...
Mise en oeuvre des framework de machines et deep learning v1
Publicité

En vedette (20)

PDF
Design applicatif avec symfony2
PDF
Méthodologie de gestion des tâches dans les projets web
PDF
Une migration sur AWS, une migration orientée produit
PDF
Qu'est ce qu'une bonne application
PDF
Anatomy of a Modern PHP Application Architecture
PDF
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
PDF
PHP 7 et Symfony 3
PDF
Edition of an Enterprise Software, Feedback
PDF
Clean architecture - PHP
PDF
Subsides bruxelles-entreprendre ondernemen-2014
PDF
10 Missions pour apprendre à créer et programmer son robot
PDF
Angularjs101-les_SPA:support de la video
PPTX
Symfony live Paris 2014 - Symfony2 sur Azure
PPT
Clean code
PDF
Software Architecture for Innovation
PDF
Symfony et Sonata Project chez Canal+
PDF
Cleancode / Tocea / Introduction
PDF
Clean architectures
PPTX
Il était une fois le Continuous Delivery chez Meetic
PDF
DDD in PHP
Design applicatif avec symfony2
Méthodologie de gestion des tâches dans les projets web
Une migration sur AWS, une migration orientée produit
Qu'est ce qu'une bonne application
Anatomy of a Modern PHP Application Architecture
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
PHP 7 et Symfony 3
Edition of an Enterprise Software, Feedback
Clean architecture - PHP
Subsides bruxelles-entreprendre ondernemen-2014
10 Missions pour apprendre à créer et programmer son robot
Angularjs101-les_SPA:support de la video
Symfony live Paris 2014 - Symfony2 sur Azure
Clean code
Software Architecture for Innovation
Symfony et Sonata Project chez Canal+
Cleancode / Tocea / Introduction
Clean architectures
Il était une fois le Continuous Delivery chez Meetic
DDD in PHP
Publicité

Similaire à Le pattern View Model avec Symfony2 (20)

PPTX
Chapitre 3--------------------------.pptx
PPTX
MVVM de A à Z
PPTX
les style d'architecture
PDF
Softfluent speig mdday2010
PPTX
Tech days 2012 mvvm de a à z
PDF
jkhkhlkhkighlihkihilhlohljlhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
PDF
3D_Evolution - Logiciel de conversions de données CAO 3D
PPTX
Introducthion mvvm avec wpf
PPTX
Architecture, bonnes pratiques et recettes pour la réussite de vos projets av...
PPTX
Architecture mvc
PPTX
Approche Mda
PPTX
Modele mvc
PPTX
Créer et intégrer son thème PrestaShop
PPTX
ASP.NET MVC, Web API & KnockoutJS
PDF
PPTX
LTA : Découverte de .NET Core
PPTX
Prezentare ASP.Net.pptx
PPTX
AngularJS
PDF
Meet up sqli lyon 09-2015 - Angular
PDF
Design applicatif avec symfony - Zoom sur la clean architecture - Symfony Live
Chapitre 3--------------------------.pptx
MVVM de A à Z
les style d'architecture
Softfluent speig mdday2010
Tech days 2012 mvvm de a à z
jkhkhlkhkighlihkihilhlohljlhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
3D_Evolution - Logiciel de conversions de données CAO 3D
Introducthion mvvm avec wpf
Architecture, bonnes pratiques et recettes pour la réussite de vos projets av...
Architecture mvc
Approche Mda
Modele mvc
Créer et intégrer son thème PrestaShop
ASP.NET MVC, Web API & KnockoutJS
LTA : Découverte de .NET Core
Prezentare ASP.Net.pptx
AngularJS
Meet up sqli lyon 09-2015 - Angular
Design applicatif avec symfony - Zoom sur la clean architecture - Symfony Live

Le pattern View Model avec Symfony2