1 / 26

DDD and Beyond … on Rails! !

DDD and Beyond … on Rails! !. Why Rails?. Ruby is awesome! Vibrant community & ecosystem CoC - less boilerplate code Supports rapid development Asset pipeline Built-in ORM – ActiveRecord And more …. Why DDD?. Powerful practices & patterns for tackling complex problems

adele
Download Presentation

DDD and Beyond … on Rails! !

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DDD and Beyond… on Rails!!

  2. Why Rails? • Ruby is awesome! • Vibrant community & ecosystem • CoC - less boilerplate code • Supports rapid development • Asset pipeline • Built-in ORM – ActiveRecord • And more …

  3. Why DDD? • Powerful practices & patterns for tackling complex problems • Both tactical and strategic • Align business & technology • Zero translations (Ubiquitous Language) • Domain experts contribute to software design • Code becomes a living description of the business • Increased clarity and understanding • Collaboration that results in well understood models • Strategic development • Prioritize resources & investment toward more complex or differentiating areas of the business • Organized architecture • Align physical systems with distinct areas of the business

  4. DDD on Rails Rails DDD Tackle complex domains Align business & technology Clarity& understanding Strategic development Organized Architecture • Ruby is awesome! • Vibrant community • Less boilerplate • Rapid development • Asset pipeline • ActiveRecord * ActiveRecord is a DDD antipattern ….

  5. DDD: Strategic Patterns • Separate areas of the business • Ideally one Domain Model per Subdomain Subdomains Ubiquitous Language • Language used & understood by all stakeholders in a project • Used to express a Domain Model • Sets the context for terms in a Ubiquitous Language • Ideally one Bounded Context per Subdomain Bounded Context

  6. Conference Management

  7. Subdomains

  8. Ubiquitous Language • Program Mgmt. Context • Organizers create Conferences • Organizers call for Proposals • Candidates submit Proposals • Once received, Reviewers rate Proposals • Organizers choose Proposals for Session topics • Access Control Context • Public Users register to create an Account • Accounts are assigned to one or more Roles • Users sign in to begin an authenticated Session

  9. Ubiquitous Language User Story:As a candidate I would like to submit a proposal to a conference So that it may be available for review

  10. Isolating Contexts Gem, Engine, App Gem, Engine, App

  11. Anticorruption Layer

  12. DDD: Tactical Patterns • Entity • Aggregate • Repository • Value Object • Domain Event • Domain Service * Building blocks of a Domain Model

  13. ActiveRecord– Schema First

  14. DDD – Model First

  15. Organizer creates a conference. ActiveRecord DDD Entity

  16. Organizer calls for proposals. ActiveRecord DDD Entity

  17. Candidate creates and submits a proposal. ActiveRecord DDD Entity

  18. Proposals can only be received once the organizer has called for proposals. ActiveRecord

  19. Proposals can only be received once the organizer has called for proposals. DDD Entity

  20. ActiveRecordvs DDD Entity ActiveRecord DDD Entity Shaped by UL Blank canvas to express UL Enforces invariants Single responsibility Encapsulate business logic • Shaped by DB schema • CRUD semantics baked in • No Encapsulation • Multiple responsibilities • Data access • Business logic • REST resource/view data

  21. Repositories • Collection semantics for an Aggregate Root • add(conference), find_by(id) etc. • Modify one Aggregate per transaction * • Consistency boundary • Watch out for false invariants • Easily implemented with NoSQL solutions • Object/Document/Key-values etc.

  22. Event Sourcing • Raise explicit event for every state change • Persist serialized events to an event store • To retrieve persisted entity • Deserializeevents and replay • Conference.allocate.replay(events)

  23. Event Sourcing & CQRS DB Query Store AsyncHandlers Events Read-only Domain Model Application Application Queries Commands Client

  24. More Information • A great DDD Introhttp://www.infoq.com/minibooks/domain-driven-design-quickly • More on CQRShttp://cqrs.wordpress.com/2010/09/08/welcome-to-cqrs-info/ • My Open Source Projecthttps://github.com/domaindrivendev/puree

More Related