Peter Morris | 3 Oct 09:31
Picon
Gravatar

Re: Broken Business Rules vs Broken Validation

In this kind of scenario I usually have a state machine on the class.
 Simple states would do

Creating,
Live

Some constraints are added if the state == Creating (Name required,
Name must be unique, etc), additional constraints are added if the
state == Live.

Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

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

Peter Morris | 3 Oct 09:36
Picon
Gravatar

Re: Cascades across aggregates

My rule is simple.

"Can the child exist without the parent?"

[Order] (Order) 1---* (Lines) [OrderLine]

If you delete the Order then its lines should also be deleted, it
makes no sense to have lines exist without an order.

[Country] (CountryOfResidence) 1--* (Residents) [Person]

Here I would use aggregation (prohibit delete) because deleting a
country should not delete lots of people, you would obviously be
deleting a country entered in error or something so you would want the
delete to fail if someone had assigned residents to it.

Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

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

Peter Morris | 3 Oct 09:53
Picon
Gravatar

Re: Is access control part of the domain?

For me there are two types of "Can I" on an object

01: Is it logical for this object to perform this task based on its state.
02: Is it permissible for the current user to perform this task.

The framework I use abstracts all of its services and provides access
via a service provider pattern.  I find this useful for many reasons
that I wont go into because I tend to talk too much :-) but one of the
advantages is that it allows you to register your own services.

Coincidentally I blogged about unit testing security only a few days ago.
http://mrpmorris.blogspot.com/2008/09/unit-testing-security.html

Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com

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

Eben Roux | 3 Oct 10:26
Favicon

Re: Customizing a domain model

Hello Jørn,

This is a typical "have your cake and eat it" scenario that customers 
think they'll need.  It ends up being utterly dumb data and as soon as 
your system (er... domain) requires knowledge of it in any way, manner, 
or form, then it absolutely has to move into the domain.  This 
typically happens when business rules enter the fray.

If, however, you can treat treat the data as dumb I would create a sub-
domain (is this right?).  I don't know if your core domain even need be 
aware of this.  Your front end sure would.

So you have a Person.  Now your generic mechanism doesn't care what the 
data belongs to.  It simply contains the ID (guid is nice, heh?), the 
type (or type name) --- Hair Colour, etc. --- and the value.  This can 
then be managed totally separate from your core domain without 
resorting to the likes of "select *".

Regards,
Eben

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

Paul Batum | 3 Oct 15:23
Picon
Gravatar

Re: Re: Cascades across aggregates

I don't think I follow your point, you say you would "use aggregation (prohibit delete)", but in your example its obvious that Person does not sit inside the Country aggregate.
When I used the term aggregate I was talking about the concept that Evans describes in DDD, as in aggregates with an identified root, not the broader definition of the word aggregate.

On Fri, Oct 3, 2008 at 8:36 AM, Peter Morris <mrpmorris <at> gmail.com> wrote:

My rule is simple.

"Can the child exist without the parent?"

[Order] (Order) 1---* (Lines) [OrderLine]

If you delete the Order then its lines should also be deleted, it
makes no sense to have lines exist without an order.

[Country] (CountryOfResidence) 1--* (Residents) [Person]

Here I would use aggregation (prohibit delete) because deleting a
country should not delete lots of people, you would obviously be
deleting a country entered in error or something so you would want the
delete to fail if someone had assigned residents to it.

Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com


__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Paul Batum | 3 Oct 15:29
Picon
Gravatar

Re: Re: Cascades across aggregates

Just as a follow up, thinking about it a bit more, it doesn't really make sense to cascade deletes across aggregate boundaries because you may be breaking referential integrity. When I asked my original question I was really more interested in hearing thoughts about cascading saves. And I still am! I got a useful answer from Bert but was hoping to get more opinions.

On Fri, Oct 3, 2008 at 2:23 PM, Paul Batum <paul.batum <at> gmail.com> wrote:
I don't think I follow your point, you say you would "use aggregation (prohibit delete)", but in your example its obvious that Person does not sit inside the Country aggregate.
When I used the term aggregate I was talking about the concept that Evans describes in DDD, as in aggregates with an identified root, not the broader definition of the word aggregate.


On Fri, Oct 3, 2008 at 8:36 AM, Peter Morris <mrpmorris <at> gmail.com> wrote:

My rule is simple.

"Can the child exist without the parent?"

[Order] (Order) 1---* (Lines) [OrderLine]

If you delete the Order then its lines should also be deleted, it
makes no sense to have lines exist without an order.

[Country] (CountryOfResidence) 1--* (Residents) [Person]

Here I would use aggregation (prohibit delete) because deleting a
country should not delete lots of people, you would obviously be
deleting a country entered in error or something so you would want the
delete to fail if someone had assigned residents to it.

Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com



__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Peter Morris | 3 Oct 15:52
Picon
Gravatar

Re: Re: Cascades across aggregates

>>I don't think I follow your point, you say you would "use aggregation (prohibit delete)", but in your example its obvious that Person does not sit inside the Country aggregate.
 
[ClassName]
(RoleName)
 
 
One order has many lines.
[Order] (Order) 1---* (Lines) [OrderLine]
 
This is a composite association, the order lines will be deleted with the order.
 
 
One country has many residents. 
[Country] (CountryOfResidence) 1--* (Residents) [Person]
 
For this I use the UML aggregate association, to indicate that the person cannot exist without a country.  Deleting a country with residents will prohibit the deletion.
 
 
Many people preferring different foods.
[Person] *------> (PreferredFood) [Food]
 
In this case there is no composition or aggregation.  If the Duck Billed Platipus were (for some unknown reason) to become suddenly extinct it is okay to delete it and have the other end unlink rather than cascade or prohibit deletion.
 
 
> When I used the term aggregate I was talking about the concept that Evans describes in DDD, as in aggregates with an identified root, not the broader definition of the word aggregate.
 
I haven't read it.  Unless I am mistaken I am using the UML term for aggregation.  If you mean something else then this would explain the confusion :-)
 
 
Pete
====
 
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Peter Morris | 3 Oct 15:54
Picon
Gravatar

Re: Re: Cascades across aggregates

>>
Just as a follow up, thinking about it a bit more, it doesn't really make sense to cascade deletes across aggregate boundaries because you may be breaking referential integrity. When I asked my original question I was really more interested in hearing thoughts about cascading saves. And I still am! I got a useful answer from Bert but was hoping to get more opinions.
<<
 
That's why an aggregated association prohibits delete of the parent, but a composite cascades the delete.  No integrity problems.  As for saves, you would need to save all objects affected by the operation otherwise you will have referential integrity problems :-)
 
 
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Paul Batum | 3 Oct 16:10
Picon
Gravatar

Re: Re: Cascades across aggregates

That would explain why I didn't follow your point earlier. The Evans concept of an aggregate is different to a UML aggregation association.

Regarding your point about losing integrity if you do not cascade saves, that is only true assuming you are performing just ONE save operation. If you save each aggregate root separately then you have no problem. However this might be more effort than simply saving one aggregate root and then relying on cascades. I thought people might be able to offer some downsides to cascades, reasons why it is better to save each root explicitly.

On Fri, Oct 3, 2008 at 2:52 PM, Peter Morris <mrpmorris <at> gmail.com> wrote:

>>I don't think I follow your point, you say you would "use aggregation (prohibit delete)", but in your example its obvious that Person does not sit inside the Country aggregate.
 
[ClassName]
(RoleName)
 
 
One order has many lines.
[Order] (Order) 1---* (Lines) [OrderLine]
 
This is a composite association, the order lines will be deleted with the order.
 
 
One country has many residents. 
[Country] (CountryOfResidence) 1--* (Residents) [Person]
 
For this I use the UML aggregate association, to indicate that the person cannot exist without a country.  Deleting a country with residents will prohibit the deletion.
 
 
Many people preferring different foods.
[Person] *------> (PreferredFood) [Food]
 
In this case there is no composition or aggregation.  If the Duck Billed Platipus were (for some unknown reason) to become suddenly extinct it is okay to delete it and have the other end unlink rather than cascade or prohibit deletion.
 
 
> When I used the term aggregate I was talking about the concept that Evans describes in DDD, as in aggregates with an identified root, not the broader definition of the word aggregate.
 
I haven't read it.  Unless I am mistaken I am using the UML term for aggregation.  If you mean something else then this would explain the confusion :-)
 


__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___
Peter Morris | 3 Oct 16:34
Picon
Gravatar

Re: Re: Cascades across aggregates

Why would you want to perform multiple save operations?  Deleting a node and all its sub-nodes is an atomic operation and should therefore occur within a single DB transaction shouldn't it?  There's probably an opinion / approach here I am unfamiliar with :-)
 
 
 
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Gmane