© 2019, Domain Driven Design Taiwan Community
Kim Kao ( )
Feb 20, 2019
Getting started with DDD
© 2019, Domain Driven Design Taiwan Community
• Pattern Name (#) : ,
• Bounded Context(2) : Bounded
Context
• Bounded Context : Bounded Context
• [reference] :
• [Evans]: Eric Evans
• [Evans, Ref]: Evans
• [Gamma et al.],[Fowler, PoEAA]: Martin
Fowler
© 2019, Domain Driven Design Taiwan Community
Strategic Design
, ,
– Ch4
PoEAA, EIP, RESTful, CQRS, Event Driven
Tactical Design Pattern
(Entity, Value Object, Repository .......)
2003 10 , DDD
:
Aggregate + Event Sourcing
© 2019, Domain Driven Design Taiwan Community
•
• Pair Mob programming
•
• https://github.com/ddd-tw
Strategic Design
, ,
– Ch4
PoEAA, EIP, RESTful, CQRS, Event Driven
Tactical Design Pattern
(Entity, Value Object, Repository .......)
2003 10 , DDD
:
Aggregate + Event Sourcing
© 2019, Domain Driven Design Taiwan Community
DDD
• (Ubiquitos Language) –
(Bounded Context,2)
•
• 1st meetup : , , ,
• :
© 2019, Domain Driven Design Taiwan Community
(Strategic Modeling)
© 2019, Domain Driven Design Taiwan Community
Ch1 – DDD
• DDD
• DDD
• DDD
• DDD
• , , DDD
DDD
© 2019, Domain Driven Design Taiwan Community
DDD
DDD WhirlPool
© 2019, Domain Driven Design Taiwan Community
• (X), (O) (O) (O) (O)
•
• !? !?
•
•
© 2019, Domain Driven Design Taiwan Community
© 2019, Domain Driven Design Taiwan Community
© 2019, Domain Driven Design Taiwan Community
© 2019, Domain Driven Design Taiwan Community
“
“
© 2019, Domain Driven Design Taiwan Community
DDD
•
..
•
• !
•
• Job security
• SA SA , SD SD ,
• , UML
•
•
• Living Document
•
•
© 2019, Domain Driven Design Taiwan Community
DDD
•
•
•
•
•
• UML ( )
• (HA, Cloud)
• DDD
•
•
•
© 2019, Domain Driven Design Taiwan Community
DDD à
CRUD
DDD
0 CRUD
25~30 ! 30
User Story Use Case Flow
1 30
30~40 User Story Use
Case Flow
2
? 3 1.
CRUD
2.
4 DDD
5 DDD
7 DDD
© 2019, Domain Driven Design Taiwan Community
Anemic Domain Model
https://www.mamanatural.com/anemia-during-pregnancy/
© 2019, Domain Driven Design Taiwan Community
• Anemic Domain Object -
•
• 2000
• Java EE, ASP.net,
•
•
• public getter/setter, ( ) ?
• xxxService,xxxApplication
getter/setter?
All Yes, or All No
© 2019, Domain Driven Design Taiwan Community
package solid.humank.domains;
public class Order {
private int quantity;
private String seatNo;
private boolean drinkHere;
private int price;
private String itemName;
private String establishTime;
private int drinktemperature;
}
© 2019, Domain Driven Design Taiwan Community
package solid.humank.domains;
import lombok.Data;
@Data
public class Order {
private int quantity;
private String seatNo;
private boolean drinkHere;
private int price;
private String itemName;
private String establishTime;
private int drinktemperature;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getSeatNo() {
return seatNo;
}
public void setSeatNo(String seatNo) {
this.seatNo = seatNo;
}
• Getter/Setter(Accessor/Mutator)
• Getter/Setter
• à
• /
• ” ” /
© 2019, Domain Driven Design Taiwan Community
• –
(O-R Mapping)
•
• xxxService, xxxApplication
• Active Record [Folwer,PoEAA]
•
• [Fowler,PoEAA] Transaction Script
© 2019, Domain Driven Design Taiwan Community
Transaction Script
• ( )
© 2019, Domain Driven Design Taiwan Community
Martin Fowler
1)
2) GoF Command Pattern
: https://bit.ly/2NfZYlH
© 2019, Domain Driven Design Taiwan Community
Transaction Script
?
• saveCustomer ?
• ( ?)
© 2019, Domain Driven Design Taiwan Community
?
•
•
•
Customer
© 2019, Domain Driven Design Taiwan Community
-1
Patient.setShotType(ShotTypes.TYPE_FLU);
Patient.setDose(dose);//
Patient.setNurse(nurse);
:
No comment from DE
• Patient setNurse ?
• Patient ShotType
• ?
© 2019, Domain Driven Design Taiwan Community
-2
Patient.giveFluShot();:
“ ”
• ?
•
© 2019, Domain Driven Design Taiwan Community
-3
Vaccine vaccine = Vaccines.standardAdultFluDose();
nurse.administerFluVaccine(patient, vaccine);
:
“ ”
•
•
• ?
© 2019, Domain Driven Design Taiwan Community
• Glossary
“ ”
• UML
• /
•
• Wiki
• Sprint planning
• Code Base
© 2019, Domain Driven Design Taiwan Community
Customer
© 2019, Domain Driven Design Taiwan Community
public interface Customer {
public void changePersonalName(String firstName, String lastName);
public void postalAddress(PostalAddress postalAddress);
public void relocateTo(PostalAddress changedPostalAddress);
public void changeHomeTelephone(Telephone telephone);
public void disconnectHomeTelephone();
public void changeMobileTelephone(Telephone telephone);
public void disconnectMobileTelephone();
public void primaryEmailAddress(EmailAddress emailAddress);
public void secondaryEmailAddress(Email Address);
}
• String à PostalAddress
• String à Telephone
• Email String à EmailAddress
• ( )
© 2019, Domain Driven Design Taiwan Community
(Ubiquitous Language)
•
•
• Scope, team matters
• (Bounded Context)
à
•
•
(Context Mapping,3)
© 2019, Domain Driven Design Taiwan Community
DDD
•
•
•
•
•
•
•
•
• (Aggregate,10) (Entity,5) (Value Object,6) (Domain Service,7)
(Domain Event 8)
© 2019, Domain Driven Design Taiwan Community
DDD
•
•
•
• ? ?
© 2019, Domain Driven Design Taiwan Community
Scrum
© 2019, Domain Driven Design Taiwan Community
Agile / Scrum ?
© 2019, Domain Driven Design Taiwan Community
: Backlog item Sprint
•
•
backlog sprint
• Client
•
scrum team, ?
© 2019, Domain Driven Design Taiwan Community
Scrum Team member,
” ”
sprint
:
backlog sprint. backlog
sprint
backlog sprint .
sprint stakeholders
© 2019, Domain Driven Design Taiwan Community
DDD
•
• ?
Transaction Script
• DDD
• Transaction Script
•
•
•
• DDD ?
© 2019, Domain Driven Design Taiwan Community
TDD
•
•
•
•
•
© 2019, Domain Driven Design Taiwan Community
Kent Beck Simple Design
1. Passes the tests
2. Reveals intention
3. No duplication
4. Fewest elements
TDD
1. Write new code only if an automated test has failed
2. Eliminate duplication
© 2019, Domain Driven Design Taiwan Community
TDD is natural fit in DDD
© 2019, Domain Driven Design Taiwan Community
DDD
• TDD
• Kata -
http://butunclebob.com/ArticleS.UncleBob.TheBowlin
gGameKata
•

2019-02-20-ddd taiwan-community-iddd-studygroup-1st

  • 1.
    © 2019, DomainDriven Design Taiwan Community Kim Kao ( ) Feb 20, 2019 Getting started with DDD
  • 2.
    © 2019, DomainDriven Design Taiwan Community • Pattern Name (#) : , • Bounded Context(2) : Bounded Context • Bounded Context : Bounded Context • [reference] : • [Evans]: Eric Evans • [Evans, Ref]: Evans • [Gamma et al.],[Fowler, PoEAA]: Martin Fowler
  • 3.
    © 2019, DomainDriven Design Taiwan Community Strategic Design , , – Ch4 PoEAA, EIP, RESTful, CQRS, Event Driven Tactical Design Pattern (Entity, Value Object, Repository .......) 2003 10 , DDD : Aggregate + Event Sourcing
  • 4.
    © 2019, DomainDriven Design Taiwan Community • • Pair Mob programming • • https://github.com/ddd-tw Strategic Design , , – Ch4 PoEAA, EIP, RESTful, CQRS, Event Driven Tactical Design Pattern (Entity, Value Object, Repository .......) 2003 10 , DDD : Aggregate + Event Sourcing
  • 5.
    © 2019, DomainDriven Design Taiwan Community DDD • (Ubiquitos Language) – (Bounded Context,2) • • 1st meetup : , , , • :
  • 6.
    © 2019, DomainDriven Design Taiwan Community (Strategic Modeling)
  • 7.
    © 2019, DomainDriven Design Taiwan Community Ch1 – DDD • DDD • DDD • DDD • DDD • , , DDD DDD
  • 8.
    © 2019, DomainDriven Design Taiwan Community DDD DDD WhirlPool
  • 9.
    © 2019, DomainDriven Design Taiwan Community • (X), (O) (O) (O) (O) • • !? !? • •
  • 10.
    © 2019, DomainDriven Design Taiwan Community
  • 11.
    © 2019, DomainDriven Design Taiwan Community
  • 12.
    © 2019, DomainDriven Design Taiwan Community
  • 13.
    © 2019, DomainDriven Design Taiwan Community “ “
  • 14.
    © 2019, DomainDriven Design Taiwan Community DDD • .. • • ! • • Job security • SA SA , SD SD , • , UML • • • Living Document • •
  • 15.
    © 2019, DomainDriven Design Taiwan Community DDD • • • • • • UML ( ) • (HA, Cloud) • DDD • • •
  • 16.
    © 2019, DomainDriven Design Taiwan Community DDD à CRUD DDD 0 CRUD 25~30 ! 30 User Story Use Case Flow 1 30 30~40 User Story Use Case Flow 2 ? 3 1. CRUD 2. 4 DDD 5 DDD 7 DDD
  • 17.
    © 2019, DomainDriven Design Taiwan Community Anemic Domain Model https://www.mamanatural.com/anemia-during-pregnancy/
  • 18.
    © 2019, DomainDriven Design Taiwan Community • Anemic Domain Object - • • 2000 • Java EE, ASP.net, • • • public getter/setter, ( ) ? • xxxService,xxxApplication getter/setter? All Yes, or All No
  • 19.
    © 2019, DomainDriven Design Taiwan Community package solid.humank.domains; public class Order { private int quantity; private String seatNo; private boolean drinkHere; private int price; private String itemName; private String establishTime; private int drinktemperature; }
  • 20.
    © 2019, DomainDriven Design Taiwan Community package solid.humank.domains; import lombok.Data; @Data public class Order { private int quantity; private String seatNo; private boolean drinkHere; private int price; private String itemName; private String establishTime; private int drinktemperature; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public String getSeatNo() { return seatNo; } public void setSeatNo(String seatNo) { this.seatNo = seatNo; } • Getter/Setter(Accessor/Mutator) • Getter/Setter • à • / • ” ” /
  • 21.
    © 2019, DomainDriven Design Taiwan Community • – (O-R Mapping) • • xxxService, xxxApplication • Active Record [Folwer,PoEAA] • • [Fowler,PoEAA] Transaction Script
  • 22.
    © 2019, DomainDriven Design Taiwan Community Transaction Script • ( )
  • 23.
    © 2019, DomainDriven Design Taiwan Community Martin Fowler 1) 2) GoF Command Pattern : https://bit.ly/2NfZYlH
  • 24.
    © 2019, DomainDriven Design Taiwan Community Transaction Script ? • saveCustomer ? • ( ?)
  • 25.
    © 2019, DomainDriven Design Taiwan Community ? • • • Customer
  • 26.
    © 2019, DomainDriven Design Taiwan Community -1 Patient.setShotType(ShotTypes.TYPE_FLU); Patient.setDose(dose);// Patient.setNurse(nurse); : No comment from DE • Patient setNurse ? • Patient ShotType • ?
  • 27.
    © 2019, DomainDriven Design Taiwan Community -2 Patient.giveFluShot();: “ ” • ? •
  • 28.
    © 2019, DomainDriven Design Taiwan Community -3 Vaccine vaccine = Vaccines.standardAdultFluDose(); nurse.administerFluVaccine(patient, vaccine); : “ ” • • • ?
  • 29.
    © 2019, DomainDriven Design Taiwan Community • Glossary “ ” • UML • / • • Wiki • Sprint planning • Code Base
  • 30.
    © 2019, DomainDriven Design Taiwan Community Customer
  • 31.
    © 2019, DomainDriven Design Taiwan Community public interface Customer { public void changePersonalName(String firstName, String lastName); public void postalAddress(PostalAddress postalAddress); public void relocateTo(PostalAddress changedPostalAddress); public void changeHomeTelephone(Telephone telephone); public void disconnectHomeTelephone(); public void changeMobileTelephone(Telephone telephone); public void disconnectMobileTelephone(); public void primaryEmailAddress(EmailAddress emailAddress); public void secondaryEmailAddress(Email Address); } • String à PostalAddress • String à Telephone • Email String à EmailAddress • ( )
  • 32.
    © 2019, DomainDriven Design Taiwan Community (Ubiquitous Language) • • • Scope, team matters • (Bounded Context) à • • (Context Mapping,3)
  • 33.
    © 2019, DomainDriven Design Taiwan Community DDD • • • • • • • • • (Aggregate,10) (Entity,5) (Value Object,6) (Domain Service,7) (Domain Event 8)
  • 34.
    © 2019, DomainDriven Design Taiwan Community DDD • • • • ? ?
  • 35.
    © 2019, DomainDriven Design Taiwan Community Scrum
  • 36.
    © 2019, DomainDriven Design Taiwan Community Agile / Scrum ?
  • 37.
    © 2019, DomainDriven Design Taiwan Community : Backlog item Sprint • • backlog sprint • Client • scrum team, ?
  • 38.
    © 2019, DomainDriven Design Taiwan Community Scrum Team member, ” ” sprint : backlog sprint. backlog sprint backlog sprint . sprint stakeholders
  • 39.
    © 2019, DomainDriven Design Taiwan Community DDD • • ? Transaction Script • DDD • Transaction Script • • • • DDD ?
  • 40.
    © 2019, DomainDriven Design Taiwan Community TDD • • • • •
  • 41.
    © 2019, DomainDriven Design Taiwan Community Kent Beck Simple Design 1. Passes the tests 2. Reveals intention 3. No duplication 4. Fewest elements TDD 1. Write new code only if an automated test has failed 2. Eliminate duplication
  • 42.
    © 2019, DomainDriven Design Taiwan Community TDD is natural fit in DDD
  • 43.
    © 2019, DomainDriven Design Taiwan Community DDD • TDD • Kata - http://butunclebob.com/ArticleS.UncleBob.TheBowlin gGameKata •