Picon

How to model this behaviour on multiple aggregates?



We currently have a model where a single aggregate models a Person (identification, address, etc) and his/her personal relationships (marriage, partnership, divorces, etc.). This aggregate is fairly large and not all use cases interested in the relations where operating on the Person aggregate, we are looking at the consequences of splitting this in two aggregates (Person and PersonRelation for instance).

As a consequence, there is no possibility to implement something like Person.marriesTo(Person.Id anotherPerson). The reason is the constraint that this is only allowed as long as this relation is not already present at the given moment (A Person cannot be married twice at the same time). This is just an example but there a number of constraints on the model with respect to a Person and his relationships.

We have identified the following options on how to implement this but are not satisfied with any of them:
* Create a domain service. This feels unnatural as the behaviour is not part of the Person that is marrying.
* Implement the behaviour on Person and provide a list of current relationships, e.g. Person.marriesTo(PersonId anotherPerson, List<Relation> currentRelations). This enables the Person to implement the required behaviour, but also requires some state (a set of aggregates) to be injected.
* Leave the orchestration to the use case implementing the behaviour. This also seems wrong, as the domain should be responsible for maintaining its integrity. A use case creating duplicate relationships cannot be prevented by the domain when using this option.
* Inject the Relation repository into Person, so existing Relation instances can be requested as part of the implementation. As I understood, this is bad practice as well.

As this seems a rather general problem, I am curious on how you guys would model this.




__._,_.___
Posted by: dennis.vredeveld <at> yahoo.com



__,_._,___
domaindrivendesign | 17 May 07:44 2016
Picon

New file uploaded to domaindrivendesign


Hello,

This email message is a notification to let you know that
a file has been uploaded to the Files area of the domaindrivendesign
group.

  File        : /Working_with_domain_events/DDD_Modelling_Current.jpg
  Uploaded by : qadd5uyfyc6k4wwrips6ogsplemgu4texkiigfex <thiel_florian <at> web.de>
  Description : 

You can access this file at the URL:
https://groups.yahoo.com/neo/groups/domaindrivendesign/files/Working_with_domain_events/DDD_Modelling_Current.jpg

To learn more about file sharing for your group, please visit:
https://help.yahoo.com/kb/index?page=content&y=PROD_GRPS&locale=en_US&id=SLN15398

Regards,

qadd5uyfyc6k4wwrips6ogsplemgu4texkiigfex <thiel_florian <at> web.de>

------------------------------------

------------------------------------

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

Working with domain events. Referencing leaf / sub-entity of aggregate



Hello everyone,


I know my topic is not new and was discussed many times before. I read a lot but not sure whether I am going the best path. So I will place this topic here again with another concrete example.


In the sales department we work with orders. Obviously this is, what a customer orders. 


A) Understanding an order with its items:

Our stakeholder often fall back and say: We need an order and order items. But this is only because of giving the “thing” an order number to talk about. Like brackets around all order items. So our understanding in the dev-Team is, the order items are aggregates and we will do something to group then by an order number.

We think of order items as aggregates, because a customer will never request an order with three items in it. Furthermore he will order three articles with a specific number. It is only for communication reasons that a number for these three items makes it easier. What do you think about that?


B) Conflict with sub-entity within order-item-aggregate

Think of order item. This is an article in a specific quantity a customer would like to have. Order item is an aggregate. Assigned to the order item there are multiple “call off”. A call off describes when the customer requests a certain quantity and whether it must be delivered (DDP) or whether it will be fetched (“ex works”). Actually call off is an aggregate on its own. Here is our conflict:

1. Sum of quantities for all call off must be less than or equal to order item quantity. So making call off an sub entity of order item seems to be the best choice, than making it an own aggregate.

2. On the other side call off will be referenced in the dispatch department. This is, because every call off leads at least to an “goods issue request” in the dispatch department. But refering to book from Eric Evans it is absolutely not allowed to reference a sub-entity - except for a single operation. It is only allowed to reference aggregates.

We are afraid of having 90% our objects being an aggregate and placing domain logic not within the aggregates but within services around two or more aggregates.


From what I have already read and got as responses from experts like Paul Rayner I should start to think about "call off" as an "domain event". Okay, it's no problem to imagine that order item will have an "customer requested quantity"-Event or something like this.


Problem is when leaving bounded context of let's say "customer care". In dispatch department it is no problem to imagine that this domain event can lead to an action and new aggregate there. At this point I do not need a reference to the "call off"/domain event. But when dispatch has problems or work is done, sales department needs to be informed that "call off" needs attention or is done and possibly order item can be given to "invocement"-bounded-context?


Is it okay, when aggregate in dispatch holds composed key on order item and sub-entity / aggregate leaf? What other possibilitites do you see? Must "call off" be an aggregate and a domain-service must check sum of call off quantities agains order item? Is this something for the "Process Manager" presented to me the first time at the DDD Europe in Belgium by Mathias Verraes?


I will be very happy getting a lot of ideas and responses. Thank you very much for reading my story :-).






__._,_.___
Posted by: thiel_florian <at> web.de



__,_._,___
Picon

Conformist

There are several types of relationships between bounded context. If A is conforming to B, does that mean
that A may directly use and reference the entities and domain services in B?

Tom

------------------------------------
Posted by: Tom Eugelink <tbee <at> tbee.org>
------------------------------------

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

How to design static master data in ddd



Hi

I have to design a static holiday calendar. That data get imported on DB level.

In the application i like to do a call like

Collection<Holidays> holidaysBetween(LocalDate from, LocalDate to)

The Holiday class has only two attributes. LocalDate and a boolean.


Is the Holiday a Aggregate? I could be a ValueObject. How do you handle static master data in DDD?

thanks




__._,_.___
Posted by: urbank <at> yahoo.com



__,_._,___
Picon

Fw: new important message



Hello!

 

New message, please read http://fatihgirisim.com/presently.php

 

marcbogaerts <at> telenet.be



__._,_.___
Posted by: <marcbogaerts <at> telenet.be>



__,_._,___
Picon

Frameworks similar to Convergent UI for composite UI



I was looking for a Java framework that could be used to compose a UI from different services/bounded contexts and it seems there aren't many options out there.


Convergent UI (inspired by Compoxure)was the only Java option I came across in my search.


I'm curious what other Java frameworks do you guys use to compose UIs?

 



__._,_.___
Posted by: songoko20000 <at> yahoo.com



__,_._,___
Picon

BoundedContexts

I was just reading this:
https://www.nginx.com/microservices-soa/?utm_source=nginx&utm_medium=homepage&utm_campaign=microservices_soa

And noticed some new "terminology".

""Realistically, there will always be some services that are shared,
even in a microservices architecture (for example, infrastructure
serv‐ ices). However, whereas SOA tries to maximize component sharing,
microservices architecture tries to minimize on sharing, through the
concept of a bounded context. One way to achieve a bounded con‐ text
and minimize dependencies in extreme cases is to violate the Don’t
Repeat Yourself (DRY) principle and replicate common func‐ tionality
across services to achieve total independence. Another way is to
compile relatively static modules into shared libraries that ser‐ vice
components can use in either a compile-time or runtime bind‐ ing. My
friend and colleague Neal Ford takes a slightly different view of this
by saying that microservices architecture is a share-nothing
architecture with the exception of two things—how services inte‐ grate
with one another, and the infrastructure plumbing to ensure
engineering consistency."

Has anyone seen the term used in this way before?

Greg

-- 
Studying for the Turing test

------------------------------------
Posted by: Greg Young <gregoryyoung1 <at> gmail.com>
------------------------------------

------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    domaindrivendesign-digest <at> yahoogroups.com 
    domaindrivendesign-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    domaindrivendesign-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

Picon

Should the "command" method do the validation?



Should validation in a domain Entity be implemented as separate method or as part of the Entity state changing method?


For example if I have event booking application where each event has limited number of places for participants. I want to check if user can make the booking or not.


Variation 1:

class Event {

  Result add(Booking booking) {

    if (fits(booking) {

      this.bookings.add(booking)

      return Result.success()

    }

    

    return Result.fail(NOT_ENOUGHT_PLACES)

  }  

}


Variation 2:

class Event {

  boolean fits(Booking booking) {

  ...

  }

  void add(Booking booking) {

    bookings.add(booking)

  }

}


Variation 3:

class Event {

  boolean fits(Booking booking) {

    ...

  }

  void add(Booking booking) {

    if (!fits(booking) {

       throw ConstraintViloationException("Cannot fit booking")

    }

    bookings.add(booking)

  }

}


Variation 1 seems nice but violates the Command and Query separation principle. Variation 2 is fragile because what if client forgets to call the fits() method. Variation 3 seems like duplicating the same check.






__._,_.___
Posted by: urgor <at> yahoo.com



__,_._,___
Picon

Should the "command" method do the validation?



Should validation in a domain Entity be implemented as separate method or as part of the Entity state changing method?


For example if I have event booking application where each event has limited number of places for participants. I want to check if user can make the booking or not.


Variation 1:

class Event {

  Result add(Booking booking) {

    if (fits(booking) {

      this.bookings.add(booking)

      return Result.success()

    }

    

    return Result.fail(NOT_ENOUGHT_PLACES)

  }  

}


Variation 2:

class Event {

  boolean fits(Booking booking) {

  ...

  }

  void add(Booking booking) {

    bookings.add(booking)

  }

}


Variation 3:

class Event {

  boolean fits(Booking booking) {

    ...

  }

  void add(Booking booking) {

    if (!fits(booking) {

       throw ConstraintViloationException("Cannot fit booking")

    }

    bookings.add(booking)

  }

}


Variation 1 seems nice but violates the Command and Query separation principle. Variation 2 is fragile because what if client forgets to call the fits() method. Variation 3 seems like duplicating the same check.






__._,_.___
Posted by: urgor <at> yahoo.com



__,_._,___
Picon

Populating new aggregates



This is about DDD, Aggregates and persistence.


In my opinion, aggregates should always be fully populated, i.e the complete graph should be loaded when reading from the database. I've seen code with lots of if's and specialized handling for both partial and fully loaded aggregates, and I think this complicates things more than necessary.


So, when reading from database, my strategy is to load complete aggregates. My question is what to do when creating new aggregates. (I know, you shouldn't talk about creating aggregates, since nothing appears out of nowhere, but just to simplify a bit...).


Let's say I'm creating a Car aggregate cons isting of already existing tires, steering wheels. What I often see, especially when using Enitiy Framework, is that the Car is being created with id references to the parts. Then the car is saved, and next time it is read from database, the actual steering wheel and tires are loaded too. That means, that the Car aggregate is not complete before it is saved. And this troubles me. For instance, I cannot ask the car if the tires are good enough before saving, or if the steering wheel actually fit or anything else that has to do with the parts of the car. So, I would like the car to be populated even before I save it.


What is the best way of populating an aggregate when creating it? Any thoughts?



__._,_.___
Posted by: ellen.lippe <at> yahoo.com



__,_._,___

Gmane