Introduction to-ddd

5,112 views
4,891 views

Published on

An introductory talk on Domain Driven Development.

Published in: Technology, Business
1 Comment
11 Likes
Statistics
Notes
  • Is there any recorded video available?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
5,112
On SlideShare
0
From Embeds
0
Number of Embeds
673
Actions
Shares
0
Downloads
130
Comments
1
Likes
11
Embeds 0
No embeds

No notes for slide

Introduction to-ddd

  1. 1. Domain Driven Designsoftware that reflects the business domain John Ferguson Smart
  2. 2. So who is this guy, anyway? Consulta nt Trainer Mentor Author Speaker Coder John Fer guson S mar t
  3. 3. What is Domain-Driven Design?
  4. 4. Domain-driven design is not atechnology or a methodology.
  5. 5. It’s a set of principles and patternsfor focusing design effort where itmatters most.
  6. 6. Basic principles
  7. 7. Basic principles Focus on the domain Domain design is based on a model
  8. 8. Basic principlesA Ubiquitous Language... ...and a shared vision
  9. 9. So what’s a model?
  10. 10. How do you represent your domain model?
  11. 11. How do you represent your domain model? Customer Account (UML) Diagrams? Branch
  12. 12. How do you represent your domain model? Detailed specifications?
  13. 13. How do you represent your domain model?Account Holder withdraws cashAs an account holderI want to withdraw cash from an ATMso 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 Free text? 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
  14. 14. How do you represent your domain model? @Test public void aCashWithdrawalShouldDeductSumFromBalance() { Account account = new Account(); account.makeDeposit(100); account.makeCashWithdraw(60); assertThat(account.getBalance(), is(40)); } Automated tests?
  15. 15. How do you represent your domain model? 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 } } Code? class Customer(val firstName : String, val lastName : String) { createAccount(accountType : AccountType) : Account } class AccountType extends Enumeration { val Current = value("CURRENT") val Savings = value("SAVINGS") }
  16. 16. The model is the mental representation Everything else is just a communication tool
  17. 17. Elaborating the model
  18. 18. Elaborating the modelA collaborative exercise
  19. 19. Elaborating the model...based on a common language
  20. 20. Elaborating the modelAccount Holder withdraws cashAs an account holderI want too withdraw cash from an ATMso 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)); } ...and expressed at all levels
  21. 21. Elaborating the modelAn evolutionary process
  22. 22. Elaborating the model So testing is essential
  23. 23. Elaborating the model Test...automated testing is essential
  24. 24. Domain-Driven Design practices
  25. 25. Domain-Driven Design architecture User Interface Presenta(on  Layer Service layer Applica(on  Layer Stateless domain knowledge and Domain  Layer business logic supporting libraries Infrastructure  Layer persistence messaging
  26. 26. Domain-Driven Design architecture Entities • Identify and state • Persistence
  27. 27. Domain-Driven Design architecture Value  Objects • No conceptual identity • Immutable
  28. 28. Domain-Driven Design architecture Services • Domain-level services • Stateless
  29. 29. Domain-Driven Design architecture Repositories • Data retrieval • Abstraction of the persistence layer
  30. 30. Domain-Driven Design architecture Factories • Creation of complex entities
  31. 31. Application code should be areflection of the business domain John  Ferguson  Smart Email:  john.smart@wakaleo.com Web:  hAp://www.wakaleo.com TwiAer:  wakaleo

×