Friday, December 6, 2013

Version 2 is almost ready:)

https://github.com/BottegaIT/ddd-leaven-v2

This time our goal was to present more advanced modeling techniques.
(but still You can learn some technical tricks, for example bullet proof locking: https://github.com/BottegaIT/ddd-leaven-v2/blob/master/src/main/java/pl/com/bottega/ddd/support/infrastructure/repository/jpa/GenericJpaRepository.java)

You can find some linguistic modeling tricks we have learned during IDDD Tour. I'll describe it in the wiki in spare time.

Wiki is still under construction, but this map should help:  http://prezi.com/akrfq7jyau8w/ddd-cqrs-leaven-v20/

Rafał Jamróz is working on more advanced testing (both Unit and jBehave) samples.

We are waiting for your comments:)


14 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I'm learning DDD-CQRS for work and this the most articulate and well explained article I found.
    Thanx alot for sharing

    ReplyDelete
  3. I'll find some free time and head space at december...
    If You have any feature/technique request than feel free to post on the group http://groups.google.com/group/ddd-cqrs-sample

    ReplyDelete
  4. Hey

    May I ask why the domain is dependent on Spring? The framework should be considered as an infrastructure which means that the domain shouldn't know it, right? What if tomorrow you would want to replace Spring with a custom framework?

    Thanks,
    Shaked

    ReplyDelete
  5. It's jus convenient...
    You can a) decouple Spring or b) abstract with own code but You can also go with "don't fight your framework" rule:P
    I'm using spring for 11 years and in my opinion it's piece of well crafted framework (only one I saw) so... no fear:)

    ReplyDelete
  6. I definitely agree with you that Spring is indeed a great framework and I have no doubt that you won't want to get rid of that, but just to get the point. I am learning how to DDD for few months now, and I am not using one language\framework so I am trying to figure what needs to be done vs what is going to actually happen:)

    Thank for the quick reply!

    ReplyDelete
  7. OK, so in general let's try to get rid of Spring... As I remember Spring is used in Domain just to inject dependencies to Aggregates, Domain Services, Respositories and Factories.

    You can get rid of Spring in Aggegates by simply injecting in Repos and Factories (that's where Aggregates are born and loaded).

    Factories, Repos and Domain Servies are used by Application Services, so You can create them there whatever You want.

    Another architectural style: Command+handlers givers You the easiest way to build custom DI - just retrospect handers before running them, seek for @Inject and inject:)

    ReplyDelete
  8. Is this still active? I am finding this as very good explanation and implementation for CQRS. Can it be taken for reference for starting new project in java with spring IOC, hibernate and integration services?

    ReplyDelete
  9. Libs and frameworks versions may be little old, but general idea is up
    to date with our commercial experience.
    We have feedback that dozens of projects are based on this Leaven.

    ReplyDelete
    Replies
    1. Thanks Slawk Sobotka. You are right that many projects are built with this framework. I have cloned git repository. Just wanted to know about any plan to extend your code for validation, authentication and authorization? Lets connect via gmail or skype.

      Delete
    2. Framework (ex. security) configuration is out of scope of our goal. But I'll ask my experts to take care of this aspects.

      Delete
  10. Hi. Reservation as aggregate root has reference to another aggregate root (Product) via ReservationItem.
    Is it implementation's compromise (pragmatic) acceptable when e.g. JPA is used as implementation technique for repositories?
    It volatiles rule of thumb that aggregates should only refer to each other via ID value. Additionally, when we would like to switch to document oriented repositories (document=aggregate) it will not work well.

    Could you advice how to approach this problems in elegant way? Getting rid of reference to Product from Reservation introduces few challenges when we deal with Offer (current price of Product is needed).

    Regards, Adam

    ReplyDelete
    Replies
    1. Simpler problem is what you ask: one aggregate need to call query (cqs, not cqrs https://en.wikipedia.org/wiki/Command%E2%80%93query_separation) method of other aggregate. Harder problem: method is command method.
      So lets generalise to command and query methods cooperation of aggregates.


      There are few ways:
      - You'll see samples where aggregate contains repo for other aggregate. Repo can load aggregated aggegates by id and save whem when dirty. I try to avoid this, because of testability and general "taste"
      - To solve command methods problem you can raise an event. Handler modifies other aggregate. If events engine is asynch you can achieve "one aggregate write per transaction" rule but face problems of modelling asynch business processes:P
      Event store can solve concurrency if events modifying product come from only one aggregate class.
      - We can remodel aggregates boundary. For example introducing something like Addition - but is it really a domain concept?
      - We can move genereOffer to domain service
      - We can introduce layers of domain model (Evans chaper 16) where dedicated Operations layer services take care of complex process steps where few aggegates are involved.

      In simple domains I would go Events... this is the road recommended by consultants but people maintaining code that models complex processes based on hundreds of events (types) curse:)

      In complex I always try to understand layers of domain (mentioned chapter 16).

      Delete