SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

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

Was ist angesagt? (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
 

Andere mochten auch

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
 
Digital Video#1
Digital Video#1Digital Video#1
Digital Video#1
danikaolson
 
โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์โกลเด้น รีทรีฟเวอร์
โกลเด้น รีทรีฟเวอร์
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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

KĂźrzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Enterprise Knowledge
 

KĂźrzlich hochgeladen (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

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.