Domain-Driven Design: Large-Scale Structure* To-ju Huang Computer Science Department University of...
-
Upload
leonard-perry -
Category
Documents
-
view
212 -
download
0
Transcript of Domain-Driven Design: Large-Scale Structure* To-ju Huang Computer Science Department University of...
Domain-Driven Design:Large-Scale Structure*To-ju HuangComputer Science Department
University of California, San Diego
April 23, 2010
1*Evans 2003 Domain-Driven Design: Tacking Complexity in the Heart of Software (Ch. 16). Addison-Wesley Longman Publishing Co., Inc.
Outline
• Motivating Example – Online Bookstore• Background
• Domain-Driven Design• Role of Large-Scale Structure
• Large-Scale Structure• Responsibility Layer• Knowledge Level• Pluggable Component Framework
• Conclusion
Motivating Example - Online Bookstore
• Requirements• Customers can place orders online• Customers can pay orders online (credit cards or PayPal)• Customers can access order, shipping, payment information• Warehouse staff can prepare and ship orders• Warehouse staff can contact distributors to restock
• Assumptions (some will change later)• Single warehouse and single seller
(i.e. the owner company itself)• No physical store (only online-purchase)
Motivating Example - Online Bookstore
order
orderline book
shipment payment
bookcatalog
stock distributor
credit cardtransaction
PayPaltransaction
courier
customer
warehouse
* *
1
1
1
*
*1
1..*
11
Motivating Example - Online Bookstore
• Modeling Challenges• We may miss the big picture when the model grows big
• Relations among entities can change on the fly; we need flexibility while obeying high-level domain restrictions
• The same high-level abstraction recurs among projects which do not work closely together; the similarity ends right here and prevents further reuse
Outline
• Motivating Example – Online Bookstore• Background
• Domain-Driven Design• Role of Large-Scale Structure
• Large-Scale Structure• Responsibility Layer• Knowledge Level• Pluggable Component Framework
• Conclusion
Domain-Driven Design
• What Domain-Driven Design is about?• Shared models serve both design and implementation teams• Communication via unified domain languages, whose
vocabulary is used to through the models• Efficient communication helps stakeholders gain and accumulate
insights, which in turn enter the unification domain language; this forms a positive feedback loop
• Relation to Model-Driven Engineering initiatives (e.g. MDA)• Both are domain engineering approaches• Both advocate the central role of models in software
development• DDD focuses more on modeling practices;
MDE initiatives are more about the development processes
7
Role of Large-Scale Structure
• Help stakeholders to grasp the high-level of the model; everybody can identify and locate his responsibility easily
• Efficient communication is assured: different teams can understand their roles and relations to the others
• Prevents teams from diverging to the point that the whole project breaks into remotely related pieces
8
Outline
• Motivating Example – Online Bookstore• Background
• Domain-Driven Design• Role of Large-Scale Structure
• Large-Scale Structure• Responsibility Layer• Knowledge Level• Pluggable Component Framework
• Conclusion
Responsibility Layer
• Layers help us track dependencies more easily, but we need more guidance on making layers
10
why 3 layers?
could this be on layers lower?
why in the same layer?
Responsibility Layer
• Some meaningful partitions may manifest themselves, by the responsibilities assumed by a group of entities
11
order
orderline book
shipment payment
bookcatalog
stock distributor
credit cardtransaction
PayPaltransaction
courier
customer
warehouse
* *
1
1
1
*
*1
1..*
1
AND, beware of the dependencies among layers
operation
capability
Responsibility Layer
• Lower layers should not know upper layers
12
order
orderline book
shipment payment
bookcatalog
stock distributor
credit cardtransaction
PayPaltransaction
courier
customer
warehouse
* *
1
1
1
*
*1
1..*
1
operation
capability
product
Responsibility Layer
• We can have more layers according to responsibilities
13
order
orderline book
shipment payment
bookcatalog
stock
distributorcredit cardtransaction
PayPaltransaction
courier
customer
warehouse
* *
1
1
1
*
*1
1..*
1
product
capability
operation
policy
decision
promotionpolicy
discount policy
pricing
discount/promotionenabler
sales report,business analysis
Outline
• Motivating Example – Online Bookstore• Background
• Domain-Driven Design• Role of Large-Scale Structure
• Large-Scale Structure• Responsibility Layer• Knowledge Level• Pluggable Component Framework
• Conclusion
Knowledge Level
• Now, the online bookstore allows 3rd-party booksellers
15
book
stock distributor
warehouse
1..*
1product
book
stock distributor
warehouse
1..*
1product
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
manufacturinginfo
Knowledge Level
• However, the company decided that some individual sellers could be bought in, so owned warehouse can be associated both kind of stock …
16
stock
warehouse
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
TOO RESTRICTED
manufacturinginfo distributor
1..*
Knowledge Level
• However, the company decided that some individual sellers could be bought in, so owned warehouse can be associated both kind of stock …
17
stock distributor
warehouse
1..*
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
stock
distributor
warehouse
1..*
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
manufacturinginfo
manufacturinginfo
Knowledge Level
• But, this is a weird that individual seller can have regular stock or owned-warehouse have manufacturing info
18
TOO LOOSE
stock
distributor
warehouse
1..*
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
manufacturinginfo
Knowledge Level
• But, this is a weird that individual seller can have regular stock
19
stock
distributor
warehouse
1..*
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
manufacturinginfo
Knowledge Level
• We introduce the warehouse type which indirectly associate stock, distributor, manufacturing info to warehouse while can only be modified by certain entities
20
stock
distributor
warehouse
1..*
individualwarehouse
owned warehouse
self-suppliedstock
regularstock
manufacturinginfo
warehouse
manufacturinginfo
distributor
warehousetype
regularstock
self-suppliedstock
1
stock
• We introduce the warehouse type which indirectly associate stock, distributor, manufacturing info to warehouse while can only be modified by certain entities
21warehouse
manufacturinginfo
distributor
warehousetype
regularstock
self-suppliedstock
1
stock
Knowledge Level
Operation Level
Outline
• Motivating Example – Online Bookstore• Background
• Domain-Driven Design• Role of Large-Scale Structure
• Large-Scale Structure• Responsibility Layer• Knowledge Level• Pluggable Component Framework
• Conclusion
Pluggable Component Framework
• Entities can be substituted by compatible plugins• However, agreed-upon standards are required…
23
order
orderline<<interface >>
product
shipment<<interface >>
payment
<<interface >>
catalog
stock<<interface >>
distributor
credit cardtransaction
PayPaltransaction
<<interface >>
courier
customer
<<interface >>
warehouse
* *
1
1
1
*
*1
1..*
1
Conclusion
• Large-scale structure helps stakeholders to understand their roles, improve communication, and keep project coherent
• Dependencies can be turned into responsibility layers with clear meanings
• Knowledge level allows flexible relations among entities while keeping the model consistent with the business logic
• Pluggable component framework, if feasible standards employed, can make high-level architecture fully utilized
24
Thank You
25