Domain Driven Design Implementation Patterns and Considerations in.NET.

Slides:



Advertisements
Similar presentations
Shyam Pather Development Manager Microsoft Session Code: DTL402.
Advertisements

Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Some questions o What are the appropriate control philosophies for Complex Manufacturing systems? Why????Holonic Manufacturing system o Is Object -Oriented.
St Louis Day of.NET 2011 Refactoring to a SOLID Foundation Steve Bohlen Senior Software Engineer SpringSource/VMware Blog:
Chapter 4 - Object-Oriented Analysis and Design in a Nutshell1 Chapter 4 Object-Oriented Analysis and Design in a Nutshell.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
St Louis Day of.NET 2011 Taming Dependency Chaos with Inversion of Control Containers Steve Bohlen Senior Software Engineer SpringSource/VMware
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Fabian Vilers Hands on ASP.NET MVC.
Craig Berntson
Ganesh Subramanian 22/12/2010
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Kansas City Developer Conference 2011 Unit Testing Patterns and Anti-Patterns Steve Bohlen Blog:
Kansas City Developer Conference 2011 Domain Driven Design Implementation Patterns and Considerations in.NET.
WEEK 4 Material Intro to Information Requirements & “Storyboarding the UCs” Monday “Paper Prototyping” Workshop by Bonnie Lecture 4b (Mon.)
UML exam advice. Minimal, yet sufficient UML course 80% of modeling can be done with 20% of the UML. Which 20% was that again? We’re supposed to be “Use.
St Louis Day of.NET 2011 Unit Testing Patterns and Anti-Patterns Steve Bohlen Senior Software Engineer SpringSource/VMware Blog:
Chapter 3 Object-Oriented Analysis of Library Management System(LMS)
+ Welcome to the Library With Ms. Krueger September 16 th, 2014.
Building SOLID Software with Dependency Injection Jeremy Rosenberg.
Domain-Driven Design using the ADO.NET Entity Framework Tim McCarthy Principal Engineer, InterKnowlogy
Use Cases College of Alameda Copyright © 2007 Patrick McDermott.
Chris Hance. Why “Re-”evolving?  NIH Epidemic  My name is Chris, and I’m a… VB6 Coder  YAGNI.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Lab 7: Simulation 3 IE332 4/21/2010
COMP 523 DIANE POZEFSKY 19 August CHAOS REIGNS.
Domain-Driven Design Tim McCarthy Principal Engineer, InterKnowlogy
Building an Offline Smart Client using Domain-Driven Design Principles Tim McCarthy.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
The DM Process – MS’s view (DMX). The Basics  You select an algorithm, show the algorithm some examples called training example and, from these examples,
1 Object-Oriented Analysis Use Case Driven. 2 The outline method for OOA 1.Identify object classes within the problem domain 2.Define the behaviour of.
A Novel Approach to Architectural Recovery in Evolving Object- Oriented Systems PhD thesis Koen De Hondt December 11, 1998.
SEA Side Software Engineering Annotations Annotation 13: Use Cases Professor Sara Stoecklin Director of Software Engineering- Panama City
S T R I C T L Y P R I V A T E A N D C O N F I D E N T I A LS T R I C T L Y P R I V A T E A N D C O N F I D E N T I A L 0 S T R I C T L Y P R I V A T E.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group
CSC 480 Software Engineering OOAD Process. Topics Overview: OOAD Process The object model Identifying classes Responsibilities and collaborations Hierarchy:
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 15: Object-Oriented Data Modeling Modern Database Management 9 h Edition Jeffrey A.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition.
Sept. 18, 2003CS WPI1 CS 509 Design of Software Systems Lecture #3 Thursday, Sept. 18, 2003.
Object-Oriented Data Modeling
Identifying Classes OO Software Design and Construction Computer Science Dept Va Tech January 2002 ©2002 McQuain WD & Keller BJ 1 Getting Started In the.
Domain Classes – Part 1.  Analyze Requirements as per Use Case Model  Domain Model (Conceptual Class Diagram)  Interaction (Sequence) Diagrams  System.
16/11/ Web Services Choreography Requirements Presenter: Emilia Cimpian, NUIG-DERI, 07April W3C Working Draft.
Training Course Domain Modeling. 2 What is the Domain model? An abstract data model A reflection of reality No ERD, closer to entity-oriented models Consists.
Domain-Driven Design for the Database-Driven Mind
Winter 2011SEG Chapter 11 Chapter 1 (Part 1) Review from previous courses Subject 1: The Software Development Process.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
CHAPTER 13: OBJECT-ORIENTED DATA MODELING (OVERVIEW) Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi © 2013 Pearson.
Aggregate In DDD. What makes an ENTITY AGGREGATE root Has global identity. Expected to be directly accessed in typical business scenarios. If it has other.
DOMAIN DRIVEN DESIGN Dave 12 May WHAT IS DDD? Set of principles to aid in building complex systems Enables us to focus on core problem domain NOT.
Asif Rehmani Trainer SharePoint-eLearning.com OFC 301.
Putting Social Media to Good Use Jeff Moriarty, Sitewire Director Social Media Strategy.
Windows Workflow Foundation Guy Burstein Senior Consultant Advantech – Microsoft Division
CMSC 202 Lesson 8 Classes II. Warmup Declare a class (.h part) named “Cup” It has a data member that says how full it is One method called “Drink” that.
Ask the Experts – Building Login-Based Sites in AEM
Peter Varhol Solutions Evangelist
Business System Development
Data Persistence In A Web Hosted World
Best Practices for Managing Security in Dynamics AX
Black Box Testing PPT Sources: Code Complete, 2nd Ed., Steve McConnell
6/16/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Unit Testing in a Team Sparkhound Presents by Steve Schaneville
SYS466 Domain Classes – Part 1.
Software Design Lecture : 15.
TechEd /17/2019 6:32 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Software Analysis.
CMSC 202 Lesson 8 Classes II.
Presentation transcript:

Domain Driven Design Implementation Patterns and Considerations in.NET

Who am I? …and why should you care? Steve Bohlen I Read Books + Write Software vs. “Read Software + Write Books” Blog, Screencast, Speak, Share, Learn

Nearly 20 years developing software LISP, Delphi, C/C++, VB, VB.NET, C# Co-Founder, NYC Alt.Net User Group Contributor: various OSS projects blog:

VirtualAlt.Net Meets weekly (monthly?) 9:00pm EST Livemeeting-based Alt.NET Topics Past Speakers: – Ayende (Oren Eini) – Jeremy Miller – Lesser-known people (like myself)

NYC CodeCamp March 6 th, 2010 Registration opens February 8 th (Monday!) Alt.NET –focused topics – Sharepoint and Silverlight too (if you‘re into that!) Come heckle Rachel Appel (the new NYC-area MS Developer Evangelist)

Beta Presentation

Opinions Ahead

Agenda Concepts Behind DDD (as needed) Implementation Patterns and Concerns for DDD Model Building Blocks in C# General DDD Coding Anti-Patterns Domain Entities Domain Value Objects Domain Repositories Domain Services Domain Validation Discussion

Common DDD Coding Anti-Patterns DDD Constructs with ‘type-suffixes’ ‘Types’ are ‘roles’ in the Domain Model Not… CustomerEntity AddressValueObject CustomerRepository ShippingService OverdueOrderSpecification Repository as glorified DAL repository.Get(int id) repository.Save(Customer c) repository.Delete(Customer c) repository.Update(Customer c)

Entities

Coding DDD Entities Distilled Identity Equality – Objects are just reference-equal by default in.NET – Equals, GetHashCode, IEquatable Identity Comparison Control of Access to Children Objects within the aggregate – Customer.AddOrder(theOrder);, Customer.RemoveOrder(theOrder); – Not Customer.Orders.Add(theOrder); Infrastructure-Ignorant – Persistent-Ignorant, UI-Ignorant, etc.

Challenges with DDD Entities Do we expose Identity value as a property? – Isn’t that a persistence-concern? – Providing a setter means the ‘identity’ of my entity can be changed by something external to it (bad!) Are General Property Setters/Getters a smell? – Means your domain is trending towards DTO-hell – Entities as property-containers for data – Non-Meaningful names for things!

Exploring Entities in Code

Value Objects

Coding DDD Value Objects Distilled Immutable – After construction, no changes to the object – Read-Only Properties Value-Equality – Equals, GetHashCode, IEquatable Property-by-Property comparison!

Challenges with DDD Value Objects Tedious to write boilerplate IEquatable implementation code by hand every time If immutable, how do we modify one? – Not entirely a trick question If no identity, how do we persist them???? – Deconstruction into basic data types?

Exploring Value Objects in Code

Repositories

Coding DDD Repositories Distilled Domain Model not tied to specific Persistence Abstract the act of query/retrieval Do so in a Domain-Centric Way – ( CustomerRepository.GetById(int id) is NOT domain-centric!) This is a data-access-layer suffixed with ’ Repository ’!

Challenges with DDD Repositories If no persistence in the Domain Model, how do we reference repositories in there? –A–Abstraction/indirection Repository Boundary blurring –O–OK for query constructs to come from outside? repos.GetBySpecification(Specification spec); –O–OK for Specification to be tied to implementation? repos.GetByCriteria(DetachedCriteria crit); –O–OK for lazy-executed queries to be returned? public IQueryable<Customer> GetCustomers() Guarding against Repository API-bloat –T–The repository is dead, long live the repository!

Exploring Repositories in Code

Services

Coding DDD Services Distilled Actions/Behaviors not belonging in Entities Injected into Entities (?) Operating Autonomously from Entities

Challenges with DDD Services Is having Services just to inject into Entities an anti-pattern? Order order = new Order(taxservice); double cost = Order.TotalWithTax(); If Services coordinate Entity interaction, who new s-up the service? Having all behavior expressed in Services and none in Entities is an anti-pattern –O–Or is it? And why?

Exploring Services in Code

Validation

Coding DDD Validation Distilled Validation is often a stand-in for ‘business rules’ –b–bool CanShipOrder(); Distinguish between persistence validation and business action validation –R–Rarely the same thing! Entity Validation –E–Entities can be valid for some things and invalid for others Place an order (if valid customer w/ a valid account) Ship an Order (if valid account and under credit limit) Value Object Validation –P–Prevent VO from entering an invalid state in the first place!

Challenges with DDD Validation Validation without ‘for what?’ is pointless –b–bool IsValid(); //??? Validation Frameworks tend to assume validation means persistence –D–Does NOT mean cannot be repurposed for Domain Validation! Where does validation happen if it requires collaboration between multiple Entities? –b–bool order.CanShipTo(customer); –b–bool customer.CanShip(order); –b–bool shippingValidator.CanShip(customer, order) –A–Anemic Domain Model Anti-Pattern?

Exploring Validation in Code

Discussion Viewpoints Experiences Values More Discussion: – – Domaindrivendesign /