introduction to-ddd
DESCRIPTION
An introductory talk on Domain Driven Development.TRANSCRIPT
![Page 1: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/1.jpg)
John Ferguson Smart
software that reflects the business domain
Domain Driven Design
![Page 2: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/2.jpg)
So who is this guy, anyway?
John Ferguson Smart
ConsultantTrainerMentorAuthorSpeakerCoder
![Page 3: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/3.jpg)
What is Domain-Driven Design?
![Page 4: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/4.jpg)
Domain-driven design is not a technology or a methodology.
![Page 5: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/5.jpg)
It’s a set of principles and patterns for focusing design effort where it matters most.
![Page 6: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/6.jpg)
Basic principles
![Page 7: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/7.jpg)
Basic principles
Focus on the domain
Domain design is based on a model
![Page 8: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/8.jpg)
Basic principles
A Ubiquitous Language...
...and a shared vision
![Page 9: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/9.jpg)
So what’s a model?
![Page 10: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/10.jpg)
![Page 11: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/11.jpg)
![Page 12: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/12.jpg)
![Page 13: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/13.jpg)
How do you represent your domain model?
![Page 14: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/14.jpg)
How do you represent your domain model?
Customer Account
Branch
(UML) Diagrams?
![Page 15: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/15.jpg)
How do you represent your domain model?
Detailed specifications?
![Page 16: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/16.jpg)
How do you represent your domain model?
Account Holder withdraws cash As an account holderI want to withdraw cash from an ATM so that I can get money out when the bank is closed
Scenario 1: Account has sufficient funds Given the account balance is $100 And the card is valid And the machine contains enough money When the Account Holder requests $20 Then the ATM should dispense $20 And the account balance should be $80 And the card should be returned
Scenario 2: Account has insufficient funds Given the account balance is $10 And the card is valid And the machine contains enough money When the Account Holder requests $20 The ATM should not dispense any money
Free text?
![Page 17: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/17.jpg)
@Test public void aCashWithdrawalShouldDeductSumFromBalance() { Account account = new Account(); account.makeDeposit(100); account.makeCashWithdraw(60); assertThat(account.getBalance(), is(40)); }
How do you represent your domain model?
Automated tests?
![Page 18: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/18.jpg)
class Account(val owner : Customer, val accountNumber : String, val accountType : AccountType, var balance : Double) {
def deposit(amount : Double) { balance += amount } def withdraw(amount : Double) { balance -= amount }}
class Customer(val firstName : String, val lastName : String) {
createAccount(accountType : AccountType) : Account}
class AccountType extends Enumeration { val Current = value("CURRENT") val Savings = value("SAVINGS")}
How do you represent your domain model?
Code?
![Page 19: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/19.jpg)
The model is the mental representation
Everything else is just a communication tool
![Page 20: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/20.jpg)
Elaborating the model
![Page 21: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/21.jpg)
Elaborating the model
A collaborative exercise
![Page 22: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/22.jpg)
Elaborating the model
...based on a common language
![Page 23: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/23.jpg)
Elaborating the model
...and expressed at all levels
Account Holder withdraws cash As an account holderI want too withdraw cash from an ATM so that I can get money out when the bank is closed
@Test public void aCashWithdrawalShouldDeductSumFromBalance() { Account account = new Account(); account.makeDeposit(100); account.makeCashWithdraw(60); assertThat(account.getBalance(), is(40));}
![Page 24: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/24.jpg)
Elaborating the model
An evolutionary process
![Page 25: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/25.jpg)
Elaborating the model
So testing is essential
![Page 26: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/26.jpg)
Elaborating the model
...automated testing is essential
Test
![Page 27: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/27.jpg)
Domain-Driven Design practices
![Page 28: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/28.jpg)
Domain-Driven Design architecture
Presenta(on Layer
Applica(on Layer
Domain Layer
Infrastructure Layer
User Interface
Service layerStateless
domain knowledge and business logic
supporting librariespersistencemessaging
![Page 29: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/29.jpg)
Domain-Driven Design architecture
Entities• Identify and state• Persistence
![Page 30: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/30.jpg)
Domain-Driven Design architecture
Value Objects• No conceptual identity• Immutable
![Page 31: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/31.jpg)
Domain-Driven Design architecture
Services• Domain-level services• Stateless
![Page 32: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/32.jpg)
Domain-Driven Design architecture
Repositories• Data retrieval• Abstraction of the persistence layer
![Page 33: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/33.jpg)
Domain-Driven Design architecture
Factories• Creation of complex entities
![Page 34: Introduction to-ddd](https://reader033.vdocuments.us/reader033/viewer/2022042510/558c785fd8b42a646c8b4730/html5/thumbnails/34.jpg)
Application code should be a reflection of the business domain
John Ferguson SmartEmail: [email protected]: hAp://www.wakaleo.com
TwiAer: wakaleo