Domain Driven Design Using.NET Dave Rael
What’s wrong with this code? Public void CallMethodThatMightThrowScaryException(int carelessInputWithoutValidation) { MethodThatMightThrowScaryException(carelessInputWithoutValidation); } catch (Exception exception) { HandleException(exception); }
“There is no try.”
Why Domain-Driven? Collaboration Ubiquitous Language Using Composition to address complexity in large systems “Not all of a large system will be well-designed.” –Eric Evans “Is BDD the same as TDD? Yes. If you’re a programmer, and your entire team is programmers, and all your stakeholders are programmers…” –Dan North
The alternative – One database schema to rule them all
Pain!
Bounded Contexts
Bounded Contexts (or Services) (or Silos)
Domain-Driven Design Ubiquitous Language Bounded Contexts Domain Events Top-Level System Architecture
Domain Driven Design Ubiquitous Language Aggregates CQRS Architecture/Implementation Within a Bounded Context
Fitting It Together public interface IDomainDrivenDesign { } public abstract class ServiceOrientedArchitecture : IDomainDrivenDesign { } public class YourDomain : ServiceOrientedArchitecture { }
Commands Sent rather than Published Imperative Issued with authority to command (within a bounded context) DestroyPlanetCommand LaunchProtonTorpedoesCommand
Events Published rather than Sent Past-tense Describe an event that has already happened “Look what I have done!” PlanetDestroyedEvent ProtonTorpedoesLaunchedEvent UrineDepositedInToiletEvent
Commands And Events Bus.Send (); Bus.Reply (); Bus.Publish ();
Stuff to Clone Loans Fines
You will use a Domain-Driven Design Approach