Domain-Driven Design for the Database-Driven Mind

Slides:



Advertisements
Similar presentations
Introduction RIMResistance is Futile, you Will be Assimilated!
Advertisements

Entity Framework Code First Migrations
.NET 3.5 SP1 New features Enhancements Visual Studio 2008 SP1 New features Enhancements Additional features/enhancements.
Shyam Pather Development Manager Microsoft Session Code: DTL402.
Domain-Driven Design Fundamentals Automated Testing for Fraidy Cats Like Me Getting Started with Entity Framework 5 Entity Framework in the Enterprise.
Craig Berntson
ORM Technologies and Entity Framework (EF)
MVC Controller Architecture Deep Dive. Holistic Look Where do controllers fit?
? Data-Driven apps and LightSwitch TechEd sessions Domain-Driven Design,.NET and Loosely-coupled approaches TechEd sessions Windows Apps Modernization.
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Rice KRAD Data Layer JPA Design Eric Westfall July 2013.
Entity Framework Code First End to End
Training Workshop Windows Azure Platform. Presentation Outline (hidden slide): Technical Level: 200 Intended Audience: Developers Objectives (what do.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Domain-Driven Design using the ADO.NET Entity Framework Tim McCarthy Principal Engineer, InterKnowlogy
The Persistence Ignorant Domain Model James Kovacs
Domain Driven Design. Set of blog posts spanning 10 months – building an app Fefactored along the way code to Patterns eg repository.
Chris Hance. Why “Re-”evolving?  NIH Epidemic  My name is Chris, and I’m a… VB6 Coder  YAGNI.
Intro to Entity Framework By Shahed Chowdhuri Don’t drown in database design during WakeUpAndCode.com.
Domain-Driven Design Tim McCarthy Principal Engineer, InterKnowlogy
Building an Offline Smart Client using Domain-Driven Design Principles Tim McCarthy.
OVERVIEW ON HOW ENTITY FRAMEWORK CODE FIRST CAN EASE THE DEVELOPMENT PROCESS Entity Framework Code First 11/19/2013 Joe Walling Copyright Walling Info.
Object Oriented Analysis and Design 1 Chapter 7 Database Design  UML Specification for Data Modeling  The Relational Data Model and Object Model  Persistence.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Domain and Persistence Patterns. Fundamental Pattern Types Design Patterns Business Logic Patterns.
Applying Domain-Driven Design Jimmy Nilsson Webcast with UML China
Entity Framework: Code First SoftUni Team Technical Trainers Software University
A U.S. Department of Energy Office of Science Laboratory Operated by The University of Chicago Argonne National Laboratory Office of Science U.S. Department.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
Data Access Layer Shahed Chowdhuri Using Code-First Migrations.
Domain Driven Design Using.NET Dave Rael. What’s wrong with this code? Public void CallMethodThatMightThrowScaryException(int carelessInputWithoutValidation)
consultant/mentor Microsoft MVP, INETA Speaker, ASPInsider, MCP, VTdotNET Leadercontact twitter theDataFarm.com/blog.
EF + DDD = true? by Jimmy Nilsson. About Jimmy Nilsson Primarily a developer and architect, but also a trainer and author Blog: JimmyNilsson.com/blog/
Entity Framework 7 Who Are You & What Have You Done to my ORM?
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.
Architecting Real-World Enterprise Application. Agenda CPR - Background Challenges in the Architecture Architecture Details Q & A Summary.
ORM Basics Repository Pattern, Models, Entity Manager Ivan Yonkov Technical Trainer Software University
2 Behind every great site, there is great data Eric Nelson Developer Evangelist Microsoft UK
DevOps with ASP.NET Core and Entity Framework Core
New Technology: Why, What ,How
Introduction to Entity framework
5/15/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
What’s new in Entity Framework Core 2.0
Entity Framework: Code First
Entity Framework DB From Code, OOP Introduction
Data centric apps for web, desktop and mobile with EF5
Entity Framework By: Casey Griffin.
End to end app development ASP.NET, WCF, WF, EF, & RIA Services
Entity Framework Core for Enterprise Applications
Learn. Imagine. Build. .NET Conf
ADO.NEXT Advances in Data Access for 2008
An Introduction to Entity Framework
.NET Database Technologies:
Entity Framework Core.
Accessing Data in a .NET Web Application
Entity Framework Core (EF Core)
Tech Ed North America /1/ :36 AM Required Slide
.NET vs. J2EE Architecture
TechEd /17/2019 6:32 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
TechEd /22/2019 9:22 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
IT College 2016, Andres käver
Entity Framework Core for Enterprise Applications
TechEd /3/ :48 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Data Structures and Database Applications ACST 3330
CloudAnt: Database as a Service (DBaaS)
Software Design Lecture 5.
02 | Beginning Code First Adam Tuliper | Technical Evangelist
Entity Framework & LINQ (Language Integrated Query)
IS 551 – Preliminary Schedule
Developer Intro to Cosmos DB
Presentation transcript:

Domain-Driven Design for the Database-Driven Mind Julie Lerman theDataFarm.com @julielerman

My Courses on Getting Started with EF6 Domain-Driven Design Fundamentals Looking Ahead to Entity Framework 7 EF6 Ninja Edition: What’s New in EF6 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 - DbContext 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

Your Workflow? Software Solution

database domain

Forget persistence? What about shared data & types? How will DDD patterns resolve with my ORM?

Value of Domain-Driven Design Patterns for Implementing Persistence for DDD

Focus on the Business Problem

Data Storage is not the Business Problem

Domain Problem Cross-Cutting Concerns Data Persistence

DDD Thinking: Divide and Conquer Bounded Context Bounded Context Bounded Context Bounded Context Human Resources Production Shipping Sales

Each Bounded Context Learn & Evolve Design with Domain Experts Software Implementation public class Customer{ } “Customer” private Customer (string Name, Date regDate){} public static Create (string Name, Date regDate){ return new Customer(name,regDate); “A Customer Registers” Register Ubiquitous Language

Domain-Driven Design Thinking Bounded Context Bounded Context Bounded Context Bounded Context Ubiquitous Language Domain Model Types Rules Ubiquitous Language Domain Model Types Rules Ubiquitous Language Domain Model Types Rules Ubiquitous Language Domain Model Types Rules

Entities: More than data containers Anemic Type for CRUD Rich Domain Model for DDD public class Schedule : Entity<Guid> { public int ClinicId { get; private set; } public DateTimeRange DateRange { get; private set; } private List<Appointment> _appointments; public IEnumerable<Appointment> Appointments {...} public Schedule(Guid id, DateTimeRange dateRange, int clinicId, IEnumerable<Appointment> appointments) : base(id) { ... MarkConflictingAppointments(); DomainEvents.Register<AppointmentUpdatedEvent>(Handle); } public Appointment AddNewAppointment(Appointment appt) { if (_appointments.Any(a => a.Id == appt)) { throw new ArgumentException(“Duplicate", "appointment"); } appt.State = TrackingState.Added; _appointments.Add(appt); public class Patient { public int Id { get; set; } public Client PetOwner { get; set; } public int ClientId { get; set; } public string Name { get; set; } public Gender Gender { get; set; } public int? DoctorId { get; set; } } private private

No Shared Data? No Shared Types? PANIC!

Data Sharing Patterns & Anti-Patterns Bad (No-Op) Read/Write from BCs to common tables Good* Read reference data from shared tables Write BC types to different tables Better Each BC persists to its own tables Best Database or DB Schema per model Even Better than Best Event Sourcing (rather than persist state) Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules

Anti-Corruption Layer Not Just for Connecting Apps Anti-Corruption Layers Services Message Queues Adapters Mappers Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules Bounded Context Ubiquitous Language Domain Model Types Rules

Shared Kernel Inheritance When to Share Types Tightly coordinated Entities and Value Objects Common schema and behavior “Reduce duplication, but not eliminate it” (Eric Evans, DDD book) Inheritance Infrastructure Not domain types Favor composition over inheritance

Domain Model and Persistence Model Data Layer Bounded Context Bounded Context Anti- Corruption Layer e.g. Mapper DB Domain Model Domain Model Persistence Model ORM Aggregate Root Aggregate Root Entities Entities Value Objects Value Objects

Domain as Persistence Model Bounded Context Anti-Corruption Layer DB Domain Model Entity Framework API, DbContext & Mappings Aggregate Root Entities Value Objects

Design with DDD, Today & Persist data with EF, Tomorrow Yes You Can Design with DDD, Today & Persist data with EF, Tomorrow

Code Sample for this session is at github Code Sample for this session is at github.com/julielerman/DomainDrivenDesignforDatabaseDrivenMind

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/DataPoints_Dec2014 Entity Framework Model Partitioning in Domain-Driven Design Bounded Contexts TechEd Europe 2014: bit.ly/TEE2014_EFDDD Coding for Domain-Driven Design: Tips for Data-Focused Devs (3 Parts) MSDN Magazine, Aug, Sept & Oct 2013 bit.ly/15xMlDL BOOKS: Domain-Driven Design, Eric Evans amzn.to/1kstiRg Implementing Domain-Driven Design, Vaughn Vernon amzn.to/1dgYRY3 Domain Modeling with Entity Framework Scorecard, Jimmy Bogard, bit.ly/1x925bu CQRS Journey from MS Patterns & Practices: bit.ly/cqrsjourney

Julie Lerman Email: julielerman@gmail.com Web: theDataFarm.com Twitter: @julielerman