Jimmy Nilsson factor10 DEVB311 About me Developerarchitect jimmynilssoncom blog Twitter JimmyNilsson Author Applying Domain Driven Design and Patterns and ID: 426136
Download Presentation The PPT/PDF document "Developing core-business applications wi..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
Developing core-business applications with DDD
Jimmy Nilsson, factor10
DEV-B311Slide3
About me
Developer/architect
jimmynilsson.com/
blog
Twitter: @JimmyNilssonAuthor”Applying Domain-Driven Design and Patterns” and”.NET Enterprise Design”CompanyCo-founder and CEO for factor10Slide4
Context
Exponential
effect
!
Dare
to
challenge
!
T
Domain
-Driven Design (DDD)Slide5
How
we as humans/developers
areSlide6Slide7Slide8Slide9Slide10Slide11Slide12Slide13
Why
Domain-Driven Design?
Latest
and
trendiest?A template in Visual Studio?The best best practice? No! Much better!
I believe that DDD can
help very much
in creating business value.Slide14
What
is software development all
about
?
$
Why
?
What
?
How
?
”
Code
!”
?
?
?
And so on…
$Slide15
Basic software
economics
Complexity
Productivity
Question
is, is it
essential
complexity
or
accidental
complexity
?Slide16
Not just
code in control
...the
size is of tremendous importance!The size…drives
costdrives bugs
drives delaysdrives team size,
which drives code size…Slide17
What
is Domain-Driven Design?
Domain
-Driven Design is an approach to the development of complex software in which we:Focus on the core domainExplore models
in a creative collaboration of domain practitioners and software
practitionersSpeak a ubiquitous language
within an explicitly bounded
context
http://domainlanguage.com/ddd/patterns/DDD_Reference_2011-01-31.pdfSlide18
Problem
and
chosen solution
Model
UmlAsASketch
Ubiquitous
Language
Code
Model
,
code
, etc...
How
do
they
fit
together
?
UISlide19
Demo
Ubiquitous language and bounded contextSlide20
Argh
!
Why
not come
up
with ten more
words for describing the same
thing…
Why
on Earth
does he
care
about
that
?
It’s
just
words
…Slide21
Ubiquitous
language
with
Behavior-Driven Development (BDD)As an insurance brokerI want to know who my gold customers are
So that I sell more
Given
customer
Sven Svensson
exists
When
he
buys
insurance
XYZ for 10000 USD
Then
he
becomes
a
gold
customer
Slide22
Demo
Learning and collaboratingSlide23
Sigh
,
he’s
coming
with
that
now!?
Sigh
,
he’s coming
with that
now
!?Slide24
A
comparison between
domain
-driven
design and database-driven design, a few simple examples”Customers have rentals”
Customer
RentalSlide25
Some
typical T-SQL
...
IF (SELECT COUNT(*) FROM
RentalLines INNER JOIN Products ON RentalLines.ProductId = Products.Id WHERE RentalId = inserted.Id AND RequiredAge > @ageOfCustomer) > 0 BEGIN ROLLBACK RAISERROR... RETURN
END UPDATE Rentals SET Status = 4 WHERE Id = inserted.IdAND Status = 3
SELECT @anError = @@ERROR, @aRowCount = @@ROWCOUNT ...Slide26
Another approach,
first try...
public
bool
CanCheckOut(){ if (status != RentalStatus.New) return false
; if (
Customer.Age < highestRequiredAgeOfAnyOfTheChosenFilms()) return
false;
return true;}
public
void
CheckOut
()
{
if
(!
CanCheckOut
())
throw
new...
...
status =
RentalStatus.CheckedOut
;
}Slide27
Transaction
Script vs Domain Model
vsSlide28
If I can only talk about one tactical pattern…Slide29
Value
ObjectsSlide30
Like this?
var
stinasEggs
= 7 * 12;var pellesEggs = 3 * 20;var theNumberOfEggsInTheBasket =
stinasEggs + pellesEggs;
Assert.AreEqual(144, theNumberOfEggsInTheBasket);
Slide31
Or like
this?
var
stinasEggs = Amount.Dozen(7);var pellesEggs = Amount.Score(3
);var
theNumberOfEggsInTheBasket = stinasEggs
+ pellesEggs;
Assert.AreEqual(144, theNumberOfEggsInTheBasket
.Count);Slide32
Architectural
styles for implementing DDDSlide33
Classic
layering
(n-
tier
)
UI
Facade
Entities
Data
Access
Tables
Most
often
very
little
focus
Traveling
recordsets...Slide34
Starting
point now
for
layering
UI
Domain
ModelSlide35
Relaxed focus on
layering, more focus on…
…
bounded
contexts!With application databases instead of integration databasesAnd balancing loose coupling and high cohesionSlide36
Maybe
you now
believe
you can benefit from DDD... Now what? What follows is definitely not a prescriptive guidance... …just an example!Slide37
Demo
“Process”Slide38
Time
report…Slide39
“Process” or more like a typical flow
A
little
strategic designA story and scenarioUI sketchingSome UmlAsASketchTransform the scenario into an acceptance testTest drive the needed pieces
Next story, and so on...Slide40
Summary
Challenge
Domain
-Driven DesignSlide41
Related content
All the presentations at this track:
Cesar de la Torre: Positioning Microsoft Development Technologies for Custom Application Development (DEV-B204)
Per
Rovegård
: Real Experience and Architectural DDD Patterns Applied on .NET (DEV-B343)
Julie
Lerman: Entity Framework in Core Business Applications and DDD Approaches (DEV-B336)
Greg Young: .NET Event Driven Applications, CQRS and Event Sourcing in Mission-Critical Applications (DEV-B401)
Miguel Castro: Understanding Dependency Injection and Those Pesky Containers (DEV-B207)Books
Eric Evans: Domain-Driven Design
Jimmy Nilsson: Applying Domain-Driven Design and Patterns
Vaughn Vernon: Implementing Domain-Driven Design
Find Me Later At this track
or at jimmy.nilsson@factor10.comSlide42
msdn
Resources for Developers
http://microsoft.com/msdn
Learning
Microsoft Certification & Training Resources
www.microsoft.com/learning
TechNet
Resources
Sessions on Demand
http://channel9.msdn.com/Events/TechEd
Resources for IT Professionals
http://microsoft.com/technet Slide43
Evaluate this session
Scan
this QR code
to
evaluate this session.
Required Slide
*delete this box when your slide is finalized
Your MS Tag will be inserted here during the final scrub. Slide44
© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.