domain driven design - garajco education 2017
TRANSCRIPT
Agenda• Domain Driven Design and the Motivation Behind• Maintaining Model Integrity• Expressing the Model• Lifecycle of Domain Objects
8
What is Domain Driven Design?
• An approach to software development for solving complex business problems.
• A mindset of developing business not only software
• A set of patterns, principles and practices
9
The Motivation Behind DDD
• Focusing on core domain
• Helping enterprise architecture and organization
• Coping with technology challenges(Enterprise frameworks, NoSQL, Microservices)
10
Conway’s Law
“Organizations which design systems are constrained to produce designs which are copies of the communication structures of these organizations.”
— Mel Conway
12
Ubiquitous Language
• One team, one language
• No need for translation
• Use in both communication and in the code
15
Hands-on Modelers
• “People who write the code
should feel responsible for the model.”
• “A modeler should not be separated
from implementation.”
20
Real Numbers• Over 6000 employees• In 400 cities and 70 countries• From 200 engineers to 2000 Engineers only in a year and half• 8000 git repositories• Over 1000 microservices
https://www.youtube.com/watch?v=kb-m2fasdDYWhat I Wish I Had Known Before Scaling Uber to 1000 Services - Matt Ranney“Scaling the traffic is not the issue. Scaling the team and the product feature release rate is the primary driver.”
21
Bounded Context• Classical divide-and-conquer strategy
• Divide large system into autonomous contexts
• Be explicit about the context responsibilites
• Each should have a refined model and a ubiquitous language
• Explicitly set boundaries and
relationships with each other
• Care about team organization, code bases, database schemas
22
Context Map• Strategic domain driven design• Very useful tool to understand overall architecture and relationships
of the system.
27
Entity
• “Many objects are not fundamentally defined by their attributes, but rather by a thread of continuity and identity. ”
• But, Identity is not always an ID.
• Anemic vs. Rich-Behaviour Domain Model
29
Domain Services
• Reflect business processes
• Mainly uses more than one entity or value object
• Should be stateless
• e.g. transferMoney
31
Aggregates• Mark one entity as root
• Contains other entities and value objects
• Apply consistency boundaries with aggregates and enforces invariants.
• External objects should not access child entity of Aggregate directly. All access operations should be done over the root
• Beginner for microservices
34
How to Decide Aggregate Root
• Which entities exist in most operations?
• Cascading delete is okay?
40
Recap• Focus on your domain
• Be explicit about your bounded contexts
• Use context map and be aware of the big picture
• Code should reveal business
41
Resources• Books
• Linkshttp://www.clipartkid.com/ubiquitous-language-cliparts/ https://morecoding.wordpress.com/2015/01/03/n-tier-architecture/ https://tommcfarlin.com/wp-content/uploads/2014/08/big-ball-of-mud.jpghttp://howtodoinjava.com/design-patterns/creational/implementing-factory-design-pattern-in-java/