SlideShare a Scribd company logo
1 of 15
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

What's hot

Velocity - NxtGen Oxford
Velocity - NxtGen OxfordVelocity - NxtGen Oxford
Velocity - NxtGen Oxford
Phil Pursglove
 

What's hot (20)

Migration from ASP.NET MVC to ASP.NET Core
Migration from ASP.NET MVC to ASP.NET CoreMigration from ASP.NET MVC to ASP.NET Core
Migration from ASP.NET MVC to ASP.NET Core
 
Skillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise - Advanced web application development
Skillwise - Advanced web application development
 
Git preso to valtech cfml team
Git preso to valtech cfml teamGit preso to valtech cfml team
Git preso to valtech cfml team
 
A User Interface for adding Machine Learning tools into GitHub
A User Interface for adding Machine Learning tools into GitHubA User Interface for adding Machine Learning tools into GitHub
A User Interface for adding Machine Learning tools into GitHub
 
Alfresco WebScript Connector for Apache ManifoldCF
Alfresco WebScript Connector for Apache ManifoldCFAlfresco WebScript Connector for Apache ManifoldCF
Alfresco WebScript Connector for Apache ManifoldCF
 
asp-net.pptx
asp-net.pptxasp-net.pptx
asp-net.pptx
 
Service-oriented architecture
Service-oriented architectureService-oriented architecture
Service-oriented architecture
 
Road Trip To Component
Road Trip To ComponentRoad Trip To Component
Road Trip To Component
 
Architecting Single Page Applications
Architecting Single Page ApplicationsArchitecting Single Page Applications
Architecting Single Page Applications
 
4 container management
4  container management4  container management
4 container management
 
Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1
 
Java SNMP Oplet
Java SNMP OpletJava SNMP Oplet
Java SNMP Oplet
 
Streams in Parallel Development by Sven Erik Knop
Streams in Parallel Development by Sven Erik KnopStreams in Parallel Development by Sven Erik Knop
Streams in Parallel Development by Sven Erik Knop
 
SpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESBSpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESB
 
Velocity - NxtGen Oxford
Velocity - NxtGen OxfordVelocity - NxtGen Oxford
Velocity - NxtGen Oxford
 
Improving page migration분산처리
Improving page migration분산처리 Improving page migration분산처리
Improving page migration분산처리
 
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
Best spring classes in navi mumbai,spring course-provider in navi-mumbai,spri...
 
FatDB Intro
FatDB IntroFatDB Intro
FatDB Intro
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails Deployment
 
Entity Framework Core 2.1: Simple, Powerful Data Access for .NET
Entity Framework Core 2.1: Simple, Powerful Data Access for .NETEntity Framework Core 2.1: Simple, Powerful Data Access for .NET
Entity Framework Core 2.1: Simple, Powerful Data Access for .NET
 

Viewers also liked

Model View Command Pattern
Model View Command PatternModel View Command Pattern
Model View Command Pattern
Akash Kava
 
Opportunity Plan Presentation - Philippines
Opportunity Plan Presentation - PhilippinesOpportunity Plan Presentation - Philippines
Opportunity Plan Presentation - Philippines
Jhun Paran
 
Competencia liderazgo
Competencia liderazgoCompetencia liderazgo
Competencia liderazgo
Tito Perez
 
Masalah yang Dihadapi Ketika Membuat Kek
Masalah yang Dihadapi Ketika Membuat KekMasalah yang Dihadapi Ketika Membuat Kek
Masalah yang Dihadapi Ketika Membuat Kek
Cik Kyra
 
โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์
PongsaTorn Sri
 
Actualog presentation for mrsk
Actualog presentation for mrskActualog presentation for mrsk
Actualog presentation for mrsk
Actualog
 
Blog pp cultural diversity
Blog pp cultural diversityBlog pp cultural diversity
Blog pp cultural diversity
PaulineHeadley
 
東京ソーシャルデザイン研究所3ドラフト
東京ソーシャルデザイン研究所3ドラフト東京ソーシャルデザイン研究所3ドラフト
東京ソーシャルデザイン研究所3ドラフト
Takayuki Toda
 
WepApps mit Play! - Nichts leichter als das
WepApps mit Play! - Nichts leichter als dasWepApps mit Play! - Nichts leichter als das
WepApps mit Play! - Nichts leichter als das
enpit GmbH & Co. KG
 
Poverty group c3
Poverty group c3Poverty group c3
Poverty group c3
Bernard Sng
 

Viewers also liked (20)

Model View Command Pattern
Model View Command PatternModel View Command Pattern
Model View Command Pattern
 
Opportunity Plan Presentation - Philippines
Opportunity Plan Presentation - PhilippinesOpportunity Plan Presentation - Philippines
Opportunity Plan Presentation - Philippines
 
Competencia liderazgo
Competencia liderazgoCompetencia liderazgo
Competencia liderazgo
 
Practica de laboratorio el microscopio
Practica de laboratorio el microscopioPractica de laboratorio el microscopio
Practica de laboratorio el microscopio
 
Why Your Public Company Doesn't Need Capital Markets Visibility 365
Why Your Public Company Doesn't Need Capital Markets Visibility 365Why Your Public Company Doesn't Need Capital Markets Visibility 365
Why Your Public Company Doesn't Need Capital Markets Visibility 365
 
Masalah yang Dihadapi Ketika Membuat Kek
Masalah yang Dihadapi Ketika Membuat KekMasalah yang Dihadapi Ketika Membuat Kek
Masalah yang Dihadapi Ketika Membuat Kek
 
Analytical thinking 12 - August 2012
Analytical thinking 12 - August 2012Analytical thinking 12 - August 2012
Analytical thinking 12 - August 2012
 
Digital Video#1
Digital Video#1Digital Video#1
Digital Video#1
 
โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์
 
Actualog presentation for mrsk
Actualog presentation for mrskActualog presentation for mrsk
Actualog presentation for mrsk
 
Vintage music rien Zubaedah
Vintage music rien ZubaedahVintage music rien Zubaedah
Vintage music rien Zubaedah
 
Actialog in pictures
Actialog in picturesActialog in pictures
Actialog in pictures
 
Blog pp cultural diversity
Blog pp cultural diversityBlog pp cultural diversity
Blog pp cultural diversity
 
Humble sparrow
Humble sparrowHumble sparrow
Humble sparrow
 
Article08
Article08Article08
Article08
 
2012 SEO For Press Releases
2012 SEO For Press Releases2012 SEO For Press Releases
2012 SEO For Press Releases
 
東京ソーシャルデザイン研究所3ドラフト
東京ソーシャルデザイン研究所3ドラフト東京ソーシャルデザイン研究所3ドラフト
東京ソーシャルデザイン研究所3ドラフト
 
Simon says stand out
Simon says stand outSimon says stand out
Simon says stand out
 
WepApps mit Play! - Nichts leichter als das
WepApps mit Play! - Nichts leichter als dasWepApps mit Play! - Nichts leichter als das
WepApps mit Play! - Nichts leichter als das
 
Poverty group c3
Poverty group c3Poverty group c3
Poverty group c3
 

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

Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 

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

Architecture Principles CodeStock
Architecture Principles CodeStock Architecture Principles CodeStock
Architecture Principles CodeStock
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and Beyond
 
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Domain Driven Design Ruby Ways -  JURNAL 05/10/2017Domain Driven Design Ruby Ways -  JURNAL 05/10/2017
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
 
Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introduction
 
Segue to design patterns
Segue to design patternsSegue to design patterns
Segue to design patterns
 
Java Spring
Java SpringJava Spring
Java Spring
 
Architectural Design & Patterns
Architectural Design&PatternsArchitectural Design&Patterns
Architectural Design & Patterns
 
Object-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency InjectionObject-Relational Mapping and Dependency Injection
Object-Relational Mapping and Dependency Injection
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overview
 
How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...
How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...
How to Structure Your Xamarin Solution by Adhering to Common .NET Practices -...
 
Software design with Domain-driven design
Software design with Domain-driven design Software design with Domain-driven design
Software design with Domain-driven design
 
Ruby on Rails & Version Control
Ruby on Rails & Version ControlRuby on Rails & Version Control
Ruby on Rails & Version Control
 
Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016Top 10 web application development frameworks 2016
Top 10 web application development frameworks 2016
 
Mastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net TricksMastering asp.net mvc - Dot Net Tricks
Mastering asp.net mvc - Dot Net Tricks
 
Hybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbaiHybernat and structs, spring classes in mumbai
Hybernat and structs, spring classes in mumbai
 
DevOps+Data: Working with Source Control
DevOps+Data: Working with Source ControlDevOps+Data: Working with Source Control
DevOps+Data: Working with Source Control
 
A Note on Distributed Computing - Papers We Love Hyderabad
A Note on Distributed Computing - Papers We Love HyderabadA Note on Distributed Computing - Papers We Love Hyderabad
A Note on Distributed Computing - Papers We Love Hyderabad
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 

Recently uploaded (20)

IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 

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.