45

Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Embed Size (px)

Citation preview

Page 1: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 2: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Developing core-business applications with DDDJimmy Nilsson, factor10

DEV-B311

Page 3: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

About meDeveloper/architectjimmynilsson.com/blog

Twitter: @JimmyNilsson

Author”Applying Domain-Driven Design and Patterns” and”.NET Enterprise Design”

CompanyCo-founder and CEO for factor10

Page 4: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Context

Exponential effect!

Dare to challenge!TDomain-Driven Design (DDD)

Page 5: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

How we as humans/developers are

Page 6: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 7: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 8: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 9: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 10: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 11: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 12: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much
Page 13: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

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.

Page 14: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

What is software development all about? $Why?

What?

How?

”Code!”

? ? ? And so on…

$

Page 15: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Basic software economics

Complexity

Productivity

Question is, is it essential complexity or accidental complexity?

Page 16: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Not just code in control

...the size is of tremendous importance!

The size…- drives cost- drives bugs- drives delays- drives team size, which drives code size…

Page 17: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

What is Domain-Driven Design?Domain-Driven Design is an approach to the

development of complex software in which we:

• Focus on the core domain

• Explore models in a creative collaboration of domain practitioners and software practitioners

• Speak a ubiquitous language within an explicitly bounded context

http://domainlanguage.com/ddd/patterns/DDD_Reference_2011-01-31.pdf

Page 18: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Problem and chosen solution

Model

UmlAsASketch

UbiquitousLanguage Code

Model, code, etc... How do they fit together?

UI

Page 19: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Demo

Ubiquitous language and bounded context

Page 20: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

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…

Page 21: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Ubiquitous language with Behavior-Driven Development (BDD)As an insurance brokerI want to know who my gold customers areSo that I sell more

Given customer Sven Svensson existsWhen he buys insurance XYZ for 10000 USDThen he becomes a gold customer

Page 22: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Demo

Learning and collaborating

Page 23: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Sigh, he’s coming with that now!?

Sigh, he’s coming with that now!?

Page 24: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

A comparison between domain-driven design and database-driven design, a few simple examples

”Customers have rentals”Customer Rental

Page 25: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

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 = 3SELECT @anError = @@ERROR, @aRowCount = @@ROWCOUNT

...

Page 26: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

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;}

Page 27: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Transaction Script vs Domain Model

vs

Page 28: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

If I can only talk about one tactical pattern…

Page 29: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Value Objects

Page 30: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Like this?var stinasEggs = 7 * 12;

var pellesEggs = 3 * 20;

var theNumberOfEggsInTheBasket = stinasEggs + pellesEggs;

Assert.AreEqual(144, theNumberOfEggsInTheBasket);

Page 31: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Or like this?var stinasEggs = Amount.Dozen(7);

var pellesEggs = Amount.Score(3);

var theNumberOfEggsInTheBasket = stinasEggs + pellesEggs;

Assert.AreEqual(144, theNumberOfEggsInTheBasket.Count);

Page 32: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Architectural styles for implementing DDD

Page 33: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Classic layering (n-tier)

UI Facade EntitiesData

AccessTables

Most often very little focus

Traveling recordsets...

Page 34: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Starting point now for layering

UI Domain Model

Page 35: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Relaxed focus on layering, more focus on……bounded contexts!

With application databases instead of integration databasesAnd balancing loose coupling and high cohesion

Page 36: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Maybe you now believe you can benefit from DDD... Now what?

What follows is definitely not a prescriptive guidance...

…just an example!

Page 37: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Demo

“Process”

Page 38: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Time report…

Page 39: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

“Process” or more like a typical flowA little strategic design

A story and scenarioUI sketchingSome UmlAsASketchTransform the scenario into an acceptance test

Test drive the needed pieces

Next story, and so on...

Page 40: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

SummaryChallenge

Domain-Driven Design

Page 41: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Related contentAll 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)BooksEric Evans: Domain-Driven DesignJimmy Nilsson: Applying Domain-Driven Design and PatternsVaughn Vernon: Implementing Domain-Driven Design

Find Me Later At this trackor at [email protected]

Page 42: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

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

Page 43: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Complete an evaluation on CommNet and enter to win!

Page 44: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

Evaluate this session

Scan this QR code to evaluate this session and be automatically entered in a drawing to win a prize

Page 45: Latest and trendiest? A template in Visual Studio? The best best practice? No! Much better! I believe that DDD can help very much

© 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.