Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Domain Driven Design 101<br />
Agenda<br />Why<br />Building blocks<br />Repositories, entities, specifications etc<br />Putting it to practice<br />Depe...
Software is complicated<br />
We solve complexity in software by distilling our problems<br />
publicboolCanBook(Cargocargo, Voyagevoyage)<br />{<br />doublemaxBooking = voyage.Capacity * 1.1;<br />if (voyage.BookedCa...
Domain Model<br />
Ubiquitous language<br />
publicinterfaceISapService<br />{<br />doubleGetHourlyRate(intsapId);<br />}<br />û<br />A poor abstraction<br />publicint...
publicclassEmployee<br />{<br />voidApplyForLeave(DateTime start,<br />DateTime end,<br />ILeaveService leaves)<br />    {...
Domain Expert<br />
Entities<br />
Value Types<br />
publicclassEmployee : IEquatable&lt;Employee&gt;<br />{<br />publicbool Equals(Employee other)<br />    {<br />returnthis....
publicclassColour<br />{<br />publicint Red { get; privateset; }<br />publicint Green { get; privateset; }<br />publicint ...
Aggregates<br />
Aggregate root<br />*<br />
Repositories<br />
publicinterfaceIEmployeeRepository<br />{<br />EmployeeGetById(int id);<br />void Add(Employeeemployee);<br />void Remove(...
Domain Services<br />
publicinterfaceITripService<br />{<br />floatGetDrivingDistanceBetween(Location a, Location b);<br />}<br />
Specifications<br />
classGoldCustomerSpecification : ISpecification&lt;Customer&gt;<br />{<br />publicboolIsSatisfiedBy(Customer candidate)<br...
Specifications can be used…<br />to construct objects<br />
var spec = newPizzaSpecification()<br />              .BasedOn(newMargaritaPizzaSpecification())<br />              .WithT...
Specifications can be used…<br />for querying<br />
publicinterfaceICustomerRepository<br />{<br />IEnumerable&lt;Customer&gt; GetCustomersSatisfying(<br />ISpecification&lt;...
Anticorruption Layer<br />
Your subsystem<br />Anti-corruption layer<br />Other subsystem<br />
Any 3rd party system that I have to integrate with was written by a drunken monkey typing with his feet.<br />Oren Eini ak...
Bounded Context<br />
publicclassLead<br />{<br />publicIEnumerable&lt;Opportunity&gt; Opportunities { get; }<br />publicPerson Contact { get; }...
Dependency Injection<br />
publicinterfaceINotificationService<br />{<br />void Notify(Employeeemployee, string message);<br />}<br />An interface de...
publicclassLeaveService<br />{<br />privatereadonlyINotificationService notifications;<br /> <br />publicLeaveService(INot...
Persistence Ignorance<br />
…ordinary  classes where you focus on the business problem at hand without adding stuff for infrastructure-related reasons...
publicclassCustomer<br />{<br />publicint Id { get; privateset; }<br />publicstringFirstName { get; set; }<br />publicstri...
[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName=&quot;AdventureWorksLTModel&quot;, Name=&quo...
Architecture<br />
Traditional Architecture<br />Presentation<br />Business Logic (BLL)<br />Infrastructure<br />Data Access (DAL)<br />
Onion Architecture<br />User Interface<br />G<br />Application Services<br />M<br />Domain Services<br />Database<br />Dom...
Onion Architecture<br />EmployeeController<br />User Interface<br />G<br />Application Services<br />M<br />IEmailSender<b...
Validation<br />
Validation Examples<br />Input validation<br />Is the first name filled in?<br />Is the e-mail address format valid?<br />...
publicclassPersonRepository : IPersonRepository<br />{<br />publicvoid Save(Person customer)<br />    {<br />if (!customer...
The golden rule for validation:<br />The Domain Model is always <br />in a valid state<br />
publicclassNewUserFormValidator : AbstractValidator&lt;NewUserForm&gt;<br />{<br />IUsernameAvailabilityServiceusernameAva...
Where validation fits<br />EmployeeController<br />User Interface<br />G<br />Application Services<br />M<br />IEmailSende...
Making Roles Explicit<br />
Challenges<br />
When DDD isn’t appropriate<br />
Benefits<br />
Books<br />
Links<br />Domain Driven Design mailing list<br />http://tech.groups.yahoo.com/group/domaindrivendesign/<br />ALT.NET mail...
Upcoming SlideShare
Loading in …5
×

[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName=&quot;AdventureWorksLTModel&quot;, Name=&quot;Customer&quot;)]<br /> [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]<br /> Domain Driven Design 101

42,949 views

Published on

[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName=&quot;AdventureWorksLTModel&quot;, Name=&quot;Customer&quot;)] [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)] [global::System.Serializable()]publicpartialclassCustomer : global::System.Data.Objects.DataClasses.EntityObject { [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] [global::System.Runtime.Serialization.DataMemberAttribute()]publicintCustomerID {get {returnthis._CustomerID; }set {this.OnCustomerIDChanging(value);this.ReportPropertyChanging(&quot;CustomerID&quot;);this._CustomerID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);this.ReportPropertyChanged(&quot;CustomerID&quot;);this.OnCustomerIDChanged(); } }privateint _CustomerID;partialvoidOnCustomerIDChanging(int value);partialvoidOnCustomerIDChanged(); This is not a POCO.

Published in: Technology, Business
  • Login to see the comments

×