SlideShare a Scribd company logo
Website Patterns
Agenda
Core Engineering Principles
• DRY
  – Don’t Repeat Yourself
• SOLID
  – Single Responsibility
  – Open Closed
  – Liskov Substitution
  – Interface Segregation
  – Dependency Inversion
Top 5 Web Debt Causes
• Controllers doing too much
• Domain Model Issues
  – Incomplete
  – Lack of constraints / incorrect cardinality
  – Circular Dependencies
• View Issues
  – Inconsistent use of Domain and View Models
  – View code is doing too much
• Database Generation
• Unnecessary WCF Service Layers
Pattern
Domain Model
• The domain model is pure POCO
• The domain model holds state and no
  behaviour.
• The domain model is the currency for all
  layers of the website from the controller to
  the repositories.
View Model
• The View Model is the state required to be
  bound to a View
• The view model object graph is in a format
  most appropriate for a View
• Validation should occur against the view
  model via Data Annotations.
• View Models are extended with helper
  method to assist the flow of View code.
Controllers
• Controllers should only have dependencies on
  Tasks
• Controllers should be responsible for calling
  the required task actions to get / save the data
  required
• Controllers call mappers to map between
  domain objects and view models
Views
• A view should only be bound to a ViewModel
  object and never expose a domain object
  directly as its model
• Logic required for views should be
  implemented as extension methods of the
  ViewModel and not directly within the view
  itself
Tasks
• A task can be viewed as the business layer for
  a domain aggregate.
• A tasks is where the behaviour for a aggregate
  domain object is implemented
• Tasks deal only with domain objects
• Tasks can make one or more repository calls to
  a Repository for the same domain aggregate.
Repository
• A single repository exists for each domain
  aggregate
• A repository will normally map 1-2-1 with tasks.
• The repository is responsible for transactional
  boundaries and compensation if required.
• A repository does not have to be solely for
  communication with a database but can be used
  for any means of data access such as
  communicating with services
ENTITY FRAMEWORK
REPOSITORIES
Domain Model
• Model First Domain using EF 4.1
  – Auto Generated POCO Entities
  – Visualisation of object relationships
  – Build time validation
• Database Generation done in SQL Scripts
Entity Framework Repositories
• Encapsulates DbContext use
• Use Commands to Encapsulate LINQ to
  Entities queries
• Object Disposal handled via Using declarations
Entity Framework Commands
• The command class is a single location where
  all commands against a database context are
  encapsulated.
• Promotes LINQ reuse across all repositories
• Centralised location of all database use of
  IQueryable
• Decorated with multiple interfaces to restrict
  access from repositories.
• Commands are the transaction boundary.

More Related Content

PPTX
Eloquent workflow: delivering data from database to client in a right way
Роман Кинякин
 
PDF
Kentico and MVC
Cheryl MacDonald
 
PPTX
Using MVC with Kentico 8
Thomas Robbins
 
PPTX
4. introduction to Asp.Net MVC - Part II
Rohit Rao
 
PPTX
Using the Kentico CMS API
Thomas Robbins
 
PPTX
AMIS OOW Review 2012 - Deel 5 Coherence - Paco van der Linden
Getting value from IoT, Integration and Data Analytics
 
PDF
Velocity - Edge UG
Phil Pursglove
 
PPTX
UWP apps development - Part 2
Jiri Danihelka
 
Eloquent workflow: delivering data from database to client in a right way
Роман Кинякин
 
Kentico and MVC
Cheryl MacDonald
 
Using MVC with Kentico 8
Thomas Robbins
 
4. introduction to Asp.Net MVC - Part II
Rohit Rao
 
Using the Kentico CMS API
Thomas Robbins
 
AMIS OOW Review 2012 - Deel 5 Coherence - Paco van der Linden
Getting value from IoT, Integration and Data Analytics
 
Velocity - Edge UG
Phil Pursglove
 
UWP apps development - Part 2
Jiri Danihelka
 

What's hot (20)

PPTX
Migration from ASP.NET MVC to ASP.NET Core
Miroslav Popovic
 
PPTX
Skillwise - Advanced web application development
Skillwise Group
 
PPT
Git preso to valtech cfml team
SaravanaMuthu Jayaraj
 
PDF
A User Interface for adding Machine Learning tools into GitHub
Rumyana Rumenova
 
PDF
Alfresco WebScript Connector for Apache ManifoldCF
Piergiorgio Lucidi
 
PPTX
asp-net.pptx
Fajar Baskoro
 
PDF
Service-oriented architecture
Shalva Usubov
 
PPTX
Road Trip To Component
Marketa Adamova
 
PPTX
Architecting Single Page Applications
Guy Nesher
 
PPTX
4 container management
Len Bass
 
PDF
Asp.Net 3 5 Part 1
asim78
 
PPT
Java SNMP Oplet
Tal Lavian Ph.D.
 
PDF
Streams in Parallel Development by Sven Erik Knop
Perforce
 
PDF
SpringPeople Introduction to Mule ESB
SpringPeople
 
PDF
Velocity - NxtGen Oxford
Phil Pursglove
 
PPTX
Improving page migration분산처리
Park Chunduck
 
PPTX
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
anshkhurana01
 
PPTX
FatDB Intro
Justin Weiler
 
PPT
Real World Rails Deployment
Alan Hecht
 
PPTX
Entity Framework Core 2.1: Simple, Powerful Data Access for .NET
Microsoft Tech Community
 
Migration from ASP.NET MVC to ASP.NET Core
Miroslav Popovic
 
Skillwise - Advanced web application development
Skillwise Group
 
Git preso to valtech cfml team
SaravanaMuthu Jayaraj
 
A User Interface for adding Machine Learning tools into GitHub
Rumyana Rumenova
 
Alfresco WebScript Connector for Apache ManifoldCF
Piergiorgio Lucidi
 
asp-net.pptx
Fajar Baskoro
 
Service-oriented architecture
Shalva Usubov
 
Road Trip To Component
Marketa Adamova
 
Architecting Single Page Applications
Guy Nesher
 
4 container management
Len Bass
 
Asp.Net 3 5 Part 1
asim78
 
Java SNMP Oplet
Tal Lavian Ph.D.
 
Streams in Parallel Development by Sven Erik Knop
Perforce
 
SpringPeople Introduction to Mule ESB
SpringPeople
 
Velocity - NxtGen Oxford
Phil Pursglove
 
Improving page migration분산처리
Park Chunduck
 
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
anshkhurana01
 
FatDB Intro
Justin Weiler
 
Real World Rails Deployment
Alan Hecht
 
Entity Framework Core 2.1: Simple, Powerful Data Access for .NET
Microsoft Tech Community
 
Ad

Viewers also liked (20)

PPTX
Model View Command Pattern
Akash Kava
 
PPT
Opportunity Plan Presentation - Philippines
Jhun Paran
 
PPTX
Competencia liderazgo
Tito Perez
 
PDF
Practica de laboratorio el microscopio
joshman valarezo
 
PPTX
Why Your Public Company Doesn't Need Capital Markets Visibility 365
IR Smartt Inc.
 
PPTX
Masalah yang Dihadapi Ketika Membuat Kek
Cik Kyra
 
DOCX
Analytical thinking 12 - August 2012
Charlotte Skornik
 
DOCX
Digital Video#1
danikaolson
 
PPT
โกลเด้น รีทรีฟเวอร์
PongsaTorn Sri
 
PPTX
Actualog presentation for mrsk
Actualog
 
PDF
Actialog in pictures
Actualog
 
PPTX
Blog pp cultural diversity
PaulineHeadley
 
PPT
Humble sparrow
Aruna Das Gupta
 
PDF
Article08
mcmarvincraig
 
PPTX
2012 SEO For Press Releases
IR Smartt Inc.
 
PPTX
東京ソーシャルデザイン研究所3ドラフト
Takayuki Toda
 
PPTX
Simon says stand out
Simon Hurry
 
KEY
WepApps mit Play! - Nichts leichter als das
enpit GmbH & Co. KG
 
PPT
Poverty group c3
Bernard Sng
 
Model View Command Pattern
Akash Kava
 
Opportunity Plan Presentation - Philippines
Jhun Paran
 
Competencia liderazgo
Tito Perez
 
Practica de laboratorio el microscopio
joshman valarezo
 
Why Your Public Company Doesn't Need Capital Markets Visibility 365
IR Smartt Inc.
 
Masalah yang Dihadapi Ketika Membuat Kek
Cik Kyra
 
Analytical thinking 12 - August 2012
Charlotte Skornik
 
Digital Video#1
danikaolson
 
โกลเด้น รีทรีฟเวอร์
PongsaTorn Sri
 
Actualog presentation for mrsk
Actualog
 
Actialog in pictures
Actualog
 
Blog pp cultural diversity
PaulineHeadley
 
Humble sparrow
Aruna Das Gupta
 
Article08
mcmarvincraig
 
2012 SEO For Press Releases
IR Smartt Inc.
 
東京ソーシャルデザイン研究所3ドラフト
Takayuki Toda
 
Simon says stand out
Simon Hurry
 
WepApps mit Play! - Nichts leichter als das
enpit GmbH & Co. KG
 
Poverty group c3
Bernard Sng
 
Ad

Similar to MVC Website Pattern The Controller, Task, Repository, Command Pattern (20)

PPTX
Architecture Principles CodeStock
Steve Barbour
 
PPTX
Entity Framework: To the Unit of Work Design Pattern and Beyond
Steve Westgarth
 
PPTX
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Jonathan Wylliem
 
PDF
Asp 1-mvc introduction
Fajar Baskoro
 
PPTX
Segue to design patterns
Rahul Singh
 
PPTX
Java Spring
AathikaJava
 
PPTX
Architectural Design & Patterns
Inocentshuja Ahmad
 
PPTX
Object-Relational Mapping and Dependency Injection
Shane Church
 
PPT
Code igniter overview
umesh patil
 
PPTX
How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...
chaturanga ranatunga
 
PDF
Software design with Domain-driven design
Allan Mangune
 
PDF
Ruby on Rails & Version Control
Yash Mittal
 
PPT
Top 10 web application development frameworks 2016
iMOBDEV Technologies Pvt. Ltd.
 
PDF
Mastering asp.net mvc - Dot Net Tricks
Gaurav Singh
 
PPT
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
PPTX
DevOps+Data: Working with Source Control
Ed Leighton-Dick
 
PDF
A Note on Distributed Computing - Papers We Love Hyderabad
Hrishikesh Barua
 
PDF
Microservices Architecture
Srinivasan Nanduri
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Architecture Principles CodeStock
Steve Barbour
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Steve Westgarth
 
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Jonathan Wylliem
 
Asp 1-mvc introduction
Fajar Baskoro
 
Segue to design patterns
Rahul Singh
 
Java Spring
AathikaJava
 
Architectural Design & Patterns
Inocentshuja Ahmad
 
Object-Relational Mapping and Dependency Injection
Shane Church
 
Code igniter overview
umesh patil
 
How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...
chaturanga ranatunga
 
Software design with Domain-driven design
Allan Mangune
 
Ruby on Rails & Version Control
Yash Mittal
 
Top 10 web application development frameworks 2016
iMOBDEV Technologies Pvt. Ltd.
 
Mastering asp.net mvc - Dot Net Tricks
Gaurav Singh
 
Hybernat and structs, spring classes in mumbai
Vibrant Technologies & Computers
 
DevOps+Data: Working with Source Control
Ed Leighton-Dick
 
A Note on Distributed Computing - Papers We Love Hyderabad
Hrishikesh Barua
 
Microservices Architecture
Srinivasan Nanduri
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 

Recently uploaded (20)

PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Software Development Methodologies in 2025
KodekX
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Software Development Methodologies in 2025
KodekX
 

MVC Website Pattern The Controller, Task, Repository, Command Pattern

  • 3. Core Engineering Principles • DRY – Don’t Repeat Yourself • SOLID – Single Responsibility – Open Closed – Liskov Substitution – Interface Segregation – Dependency Inversion
  • 4. Top 5 Web Debt Causes • Controllers doing too much • Domain Model Issues – Incomplete – Lack of constraints / incorrect cardinality – Circular Dependencies • View Issues – Inconsistent use of Domain and View Models – View code is doing too much • Database Generation • Unnecessary WCF Service Layers
  • 6. Domain Model • The domain model is pure POCO • The domain model holds state and no behaviour. • The domain model is the currency for all layers of the website from the controller to the repositories.
  • 7. View Model • The View Model is the state required to be bound to a View • The view model object graph is in a format most appropriate for a View • Validation should occur against the view model via Data Annotations. • View Models are extended with helper method to assist the flow of View code.
  • 8. Controllers • Controllers should only have dependencies on Tasks • Controllers should be responsible for calling the required task actions to get / save the data required • Controllers call mappers to map between domain objects and view models
  • 9. Views • A view should only be bound to a ViewModel object and never expose a domain object directly as its model • Logic required for views should be implemented as extension methods of the ViewModel and not directly within the view itself
  • 10. Tasks • A task can be viewed as the business layer for a domain aggregate. • A tasks is where the behaviour for a aggregate domain object is implemented • Tasks deal only with domain objects • Tasks can make one or more repository calls to a Repository for the same domain aggregate.
  • 11. Repository • A single repository exists for each domain aggregate • A repository will normally map 1-2-1 with tasks. • The repository is responsible for transactional boundaries and compensation if required. • A repository does not have to be solely for communication with a database but can be used for any means of data access such as communicating with services
  • 13. Domain Model • Model First Domain using EF 4.1 – Auto Generated POCO Entities – Visualisation of object relationships – Build time validation • Database Generation done in SQL Scripts
  • 14. Entity Framework Repositories • Encapsulates DbContext use • Use Commands to Encapsulate LINQ to Entities queries • Object Disposal handled via Using declarations
  • 15. Entity Framework Commands • The command class is a single location where all commands against a database context are encapsulated. • Promotes LINQ reuse across all repositories • Centralised location of all database use of IQueryable • Decorated with multiple interfaces to restrict access from repositories. • Commands are the transaction boundary.