Skip to content

ddd-cqrs-es/NoBodyToBuild

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NoBodyToBuild

Imagine a team of gasp body builders that has to appoint a team member as the new chairman. The rules are:

  • Only members of the team can become chairman.
  • Only members who have been a member for at least two years can become chairman.

SampleA1/A2/B1/B2 demonstrate appointing a member as the chairman using an application service that orchestrates the collaboration of a Team object and a TeamMember object.

SampleC/E demonstrate the use of application and domain service, but this time putting the rule in the domain service and indirectly exposing more state on the Team/TeamMember object.

SampleD recognizes the temporal nature of the chairmanship and turns it into an explicit concept, using the collaboration of a Team object and a TeamMember object as factory.

At no point is state exposed. The choice boils down to Query methods (CQS style), Double Dispatch methods (Tell Don't Ask style), or Guard methods.

The questions are, regardless of this example being absurdly trivial,

  • why would you pick one or the other from an

    • encapsulation perspective?
    • information hiding perspective?
    • modeling perspective?
    • language perspective?
    • maintainability perspective?
    • readability perspective?
    • coupling perspective?
  • could you motivate why you feel more comfortable with one approach over another or why you think some of them are complete bullocks or would be a bad idea in the long term?

Feel free to fork, add your own preferred approach, play domain expert and tweak where you see fit.

P.S. Yes, I didn't write tests. Yes, those would have given valuable feedback as well. This is exploration without tests.

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%