Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph...

33
Discovering the value of Domain- Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems

Transcript of Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph...

Page 1: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Discovering the value of Domain-Driven

Design

Discovering the value of Domain-Driven

Designpresented by Herman Lintvelt

(c) 2011 Polymorph Systems

Page 2: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Do the right thing, and do the thing right.

“When we first set out to write software, we never know enough.”

Page 3: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

?What are some of the prominent problems you struggle with in your software development projects?

Page 4: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

?When faced with these problems or complex requirements, how do you go about to resolve them?

Page 5: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

An Experiment

In which we make use of volunteers to do some role-playing.

Page 6: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Scenario A

Page 7: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Scenario A

Page 8: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Scenario B

Page 9: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Scenario B

Page 10: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Scenario B

Page 11: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

So what was the difference?

• Build up a model of the domain to enhance understanding

• Based on this a common language was being developed

• New understanding immediately fed into model and language

Page 12: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Coming to terms...• Domain:

• subject area to which solution must be applied

• Domain Model:

• simplification of real world

• abstracts aspects relevant to solving problem at hand

• not just a particular diagram

• Ubiquitous Language:

• everywhere the same language

Page 13: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

What is DDD?•DDD is both way of thinking and set of

priorities

• aimed to accelerate software dealing with complex domains

• primary focus on domain and domain logic

• complex domain designs should be based on a model

• Two development practices prerequisites:

1.Development is iterative

2.Developers and domain experts have a close relationship

Page 14: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Where does DDD fit?• DDD is not a new idea!

• Central part of OO Analysis & Design

ModelModel

LanguLanguageageCodeCode

Page 15: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

?What are different nouns that can be used for “car”?

Page 16: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

• car

• vehicle

• bakkie

• automobile

• SUV

• minibus

• HMUV (High Mobility Utility Vehicle)

• jamjar (Cockney slang)

Page 17: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 05.1.7 [Req-XXXX] - Car Finder

Allow the end user to locate itself and the vehicle.

Page 18: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 0- (SoapRequest*) GetLastKnownVehiclePosition:

(id <SoapDelegate>) handler

uiTokenID: (NSString*) uiTokenID

vehicleRegistrationNr: (NSString*) vehicleRegistrationNr;

- (SoapRequest*) UnitPlayback:

(id <SoapDelegate>) handler

uiTokenID: (NSString*) uiTokenID

dtStartDate: (NSDate*) dtStartDate

dtEndDate: (NSDate*) dtEndDate

liCustomerVehicleID: (long) liCustomerVehicleID;

Page 19: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 0

Page 20: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 1As a user of the XXXX iphone application

I want to view my current location and my car’s location on a map, with the shortest route indicated visually

So that I can easily find my car

Page 21: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 1

Page 22: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 1

Page 23: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Case Study 1• The direct benefits we gained in project:

• Simpler code

• better separation in layers

• Faster development

• requirements, code & tests could be verified against domain model

• easier to debug & refactor in domain layer than in UI, Persistence, Web-service layers

• Focused on correct user stories

• Better tested

• Team interaction & communication improved dramatically

Page 24: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Utility of a Model• In DDD, the Model has 3 basic uses:

1.The model and the heart of the design shape each other

• makes model relevant, ensures the analysis applies to final product

2.The model is a backbone of a language used by all team members

3.The model is distilled knowledge

• team’s agreed way of structuring domain knowledge and key domain elements

Page 25: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

DDD and DSLs•DSL “allows solutions to be

expressed more clearly and closer to the domain”

•Model can be expressed as DSL

•DSL can be used to

•generate scaffolding code

•generate specification and test docs

•define business (domain) rules

ModelModel

LanguLanguageageCodeCode

Page 26: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Ingredients of Effective Modeling

1.Binding the model and the implementation

2.Cultivating a language based on the model

• can also include technical terms to be taught to domain experts

3.Developing a knowledge-rich model

• Objects not just data scheme (anemic objects), but has behaviour and enforce rules

4.Distilling the model

5.Brainstorming and experimenting

• Agile modeling, Model out Loud

Page 27: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Deep Domain Model

•When faced with complexity, do you

•deepen your domain knowledge

•OR deepen your technology stack?

Page 28: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Sad ExampleClient: “Our system is very expensive to maintain, and performance is horrible”

Me: “Why do you think?”

Client: “Well, cause we’re using Java and it is really slow and has a high learning curve”

Me: “Interesting. Tell me about the business domain of the system...”

Client: “Well, we’re integrating with a legacy system and use Java EE and added ESB to help with that....”

Page 29: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

Modeling out Loud• People has a genius for spoken language

• Unfortunately they usually don’t use the language of domain model when speaking

• We must harness linguistic ability to the modeling effort

• It complements the visual/spatial reasoning done by sketching diagrams

• As we model out loud, we find easier ways to say what we need to say

• NB to then take those new ideas back to the diagrams and code

Page 30: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

?Discuss what you see as benefits of DDD that applies to your current projects of software development circumstances?

What benefits will you gain if you start thinking and designing more domain-focused? (short, medium, long term?)

Page 31: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

DDD Benefits•Allows effective collaboration

•Earlier experience feed back into model and understanding of whole team

•Helps focus requirement analysis

•Allows evolving of model over time

•“When we first set out to write software, we never know enough.”

Page 32: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

References•Applying UML and Patterns,

Prentice Hall - Craig Larman

•Domain Driven Design, Addison-Wesley - Eric Evans

Page 33: Discovering the value of Domain-Driven Design presented by Herman Lintvelt (c) 2011 Polymorph Systems.

If you want...•contact me:

[email protected]

•http://www.polymorph.co.za

• twitter: hermanlintvelt

•blog: http://blog.richclientgui.com

• training: http://jtraining.co.za

•OO A&D Course, CapeTown, end of July

•Thank you