• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
DDD eXchange 2010: Udi Dahan on Architectural Innovation: CQRS
 

DDD eXchange 2010: Udi Dahan on Architectural Innovation: CQRS

on

  • 5,517 views

 

Statistics

Views

Total Views
5,517
Views on SlideShare
3,275
Embed Views
2,242

Actions

Likes
4
Downloads
138
Comments
1

6 Embeds 2,242

http://skillsmatter.com 2235
https://skillsmatter.com 2
http://smash 2
http://static.slidesharecdn.com 1
http://85.92.75.112 1
http://192.168.56.101 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • For more details and podcasts from the DDD eXchange 2010 go to http://skillsmatter.com/event-details/podcast/ddd-exchange-2010
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Same rules for insurance, finance, retail, online gambling, etc.These are technical constraints.We’d expect domain logic like in the previous slide to change often, these rules hardly ever change.
  • Thousands of years of paper-based business worked around this just fine, even though the latency increased the chance of these “concurrency conflict”

DDD eXchange 2010: Udi Dahan on Architectural Innovation: CQRS DDD eXchange 2010: Udi Dahan on Architectural Innovation: CQRS Presentation Transcript

  • CQRS & Domain Models
    Udi Dahan – The Software Simplist
    Enterprise Development Expert & SOA Specialist
  • What most architecture looks like
  • Common Mistakes #1
    Assuming that layers == tiers
    We can deploy the same components both client-side and server-side
  • But where do business rules go?
    Here?
    Here?
    Here?
    Here?
    Here?
    Here?
  • Code Reuse On A Pedestal
    Understanding existing code takes longer
    than writing new code
  • Too Much Of A “Good Thing”
  • For Example - CQRS
    Queries
    View Model
    UI
    Queries
    Commands
    Publish
    WS
    Input
    Validation
    Validation
    Rules
    View Model
    Updater
    DB
  • Common Mistake #2
    Assuming that all rules are equally likely to change
  • Rules We Know How To Handle
    In the domain model only:
    When a customer cancels an order,
    if the order was already shipped,
    charge the customer $$
    unless customer is {some status}
    DB
  • Rules We Struggle With
    Where to enforce these rules?
    - First name less than N chars
    - Username must be unique
    Not Domain Logic!
    DB
  • The Domain Model When To Use It & When Not To
    “If you have complicated and everchanging business rules…”
    “If you have simple not-null checks and a couple of sums to calculate, a Transaction Script is a better bet”
    -- Martin Fowler, p119
    Patterns of Enterprise Application Architecture
  • Common Mistake #3
    Assuming that race conditions affect the domain
  • Race Conditions
    Cancel Order
    Ship Order
    We think this should fail
  • What Domain Events Are For
    What else needs to happen?
    When a customer cancels an order,
    if the order was already shipped,
    charge the customer $$
    unless customer is {some status}
    DomainEvents.Raise<InvokeCancellationFee>(
    f => f.OrderId = msg.OrderId );
  • Consider The Reverse
    Going to ship a cancelled order
    Race condition between command & query
    “One in a million” failure
    Let it fail asynchronously
    Email back to the user
    “Sorry, that order doesn’t exist anymore”
  • Aggregate Mistakes
    public class Customer
    {
    publicvoidMakePreferred()
    {
    foreach(Ordero inthis.UnbilledOrders)
    o.Discount(10.Percent);
    }
    }
  • In Closing
    Avoid the common mistakes:
    #1 Layers & tiers
    #2 Rate of rule change
    #3 Race Conditions
    Think about aggregates & bounded contexts
  • Thank you
    Udi Dahan – The Software Simplist
    Enterprise Development Expert & SOA Specialist
    www.UdiDahan.com
    email@UdiDahan.com