DomainDriven Design for the DatabaseDriven Mind Julie Lerman
Domain-Driven Design for the Database-Driven Mind Julie Lerman the. Data. Farm. com @julielerman
My Courses on Getting Started with EF 6 Domain-Driven Design Fundamentals Looking Ahead to Entity Framework 7 EF 6 Ninja Edition: What’s New in EF 6 Automated Testing for Fraidy Cats Like Me Getting Started with Entity Framework 5 Entity Framework in the Enterprise Entity Framework Code First Migrations Data Layer Validation with Entity Framework 4. 1+ Entity Framework 4. 1 - Db. Context Data Access Entity Framework 4. 1 - Code First Querying the Entity Framework Designer Supported EDM Customization Entity Framework and Data Models Entity Framework 4. 0 By Example © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Your Workflow? © DEVintersection. All rights reserved. http: //www. DEVintersection. com
database domain © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Forget persistence? What about shared data & types? How will DDD patterns resolve with my ORM? © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Value of Domain-Driven Design Patterns for Implementing Persistence for DDD © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Business Problem © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Data Storage is not the Business Problem © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Cross-Cutting Concerns © DEVintersection. All rights reserved. http: //www. DEVintersection. com
DDD Thinking: Divide and Conquer © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Each Bounded Context public class Customer{ “Customer” “A Customer Registers” private Customer (string Name, Date reg. Date){} public static Create Register (string Name, Date reg. Date){ return new Customer(name, reg. Date); } © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Domain-Driven Design Thinking © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Entities: More than data containers Anemic Type for CRUD public class Patient { public int Id { get; set; } public Client Pet. Owner { get; set; } public int Client. Id { get; set; } public string Name { get; set; } public Gender { get; set; } public int? Doctor. Id { get; set; } } Rich Domain Model for DDD private © DEVintersection. All rights reserved. http: //www. DEVintersection. com
No Shared Data? No Shared Types? PANIC © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Data Sharing Patterns & Anti-Patterns Bad (No-Op) Good* Better Best Even Better than Best © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Anti-Corruption Layer Not Just for Connecting Apps © DEVintersection. All rights reserved. http: //www. DEVintersection. com
When to Share Types § Shared Kernel o o o Tightly coordinated Entities and Value Objects Common schema and behavior “Reduce duplication, but not eliminate it” (Eric Evans, DDD book) § Inheritance o o o Infrastructure Not domain types Favor composition over inheritance © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Domain Model and Persistence Model Domain Model Aggregate Root ORM DB Entities Value Objects © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Domain as Persistence Model Domain Model Aggregate Root Entities Value Objects Entity Framework API, Db. Context & Mappings DB © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Yes You Can © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Code Sample for this session is at github. com/julielerman/Domain. Driven. Designfor. Database. Driven. Mind © DEVintersection. All rights reserved. http: //www. DEVintersection. com
Resources MY STUFF: Domain-Driven Design Fundamentals on Pluralsight bit. ly/PS-DDD All of my Pluralsight courses: pluralsight. com/author/julie-lerman A Pattern for Sharing Data Across DDD Bounded Contexts (Part 1&2) MSDN Magazine, Oct & Dec 2014: bit. ly/Data. Points_Dec 2014 Entity Framework Model Partitioning in Domain-Driven Design Bounded Contexts Tech. Ed Europe 2014: bit. ly/TEE 2014_EFDDD Coding for Domain-Driven Design: Tips for Data-Focused Devs (3 Parts) MSDN Magazine, Aug, Sept & Oct 2013 bit. ly/15 x. Ml. DL BOOKS: Domain-Driven Design, Eric Evans amzn. to/1 ksti. Rg Implementing Domain-Driven Design, Vaughn Vernon amzn. to/1 dg. YRY 3 Domain Modeling with Entity Framework Scorecard, Jimmy Bogard, bit. ly/1 x 925 bu CQRS Journey from MS Patterns & Practices: bit. ly/cqrsjourney © DEVintersection. All rights reserved. http: //www. DEVintersection. com
- Slides: 23