CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

Got the new book, got the latest code, got questions...

Last post 01-08-2009, 10:36 AM by dctc42. 4 replies.
Sort Posts: Previous Next
  •  01-02-2009, 1:04 PM 29439

    Got the new book, got the latest code, got questions...

    ...I'll start with an easy one first.

    Why was the Parent property in business base marked as internal?

    I've used this property in application code (cast to a concrete bo type), is this considered bad design?

  •  01-02-2009, 10:17 PM 29453 in reply to 29439

    Re: Got the new book, got the latest code, got questions...

    Hi,

    With respect to your question about bad design - I wouldn't say that it is bad, but some may consider it a bit "smelly", ie., it COULD indicate some design problems.  But then again, if you've considered that this is the best way to go, then it could be okay for the particular case you are coding for.

    The Domain Driven Design (DDD) approach is to reference all children of the aggregate through the aggregate root.  It's fine to have transitory direct references to children from code outside of the aggregate, however, in general you should channel all referencing through the root.  This helps keep references under control, avoiding any potential memory and invalid reference problems.

    "An AGGREGATE is a cluster of associated objects that we treat as a unit for the purpose of data changes. Each AGGREGATE has a root and a boundary. The boundary defines what is inside the AGGREGATE. The root is a single, specific ENTITY contained in the AGGREGATE. The root is the only member of the AGGREGATE that outside objects are allowed to hold references to, although objects within the boundary may hold references to each other." - Domain Driven Design, by Eric Evans

    So, I guess what I am getting at is - if you've got a reference to the child already, shouldn't you also already know who the parent is (since you would have obtained it through the root)?  But, like I said, you could be addressing a corner case in which case your current design could be perfectly valid.

    Leigh

  •  01-07-2009, 3:00 PM 29546 in reply to 29453

    Re: Got the new book, got the latest code, got questions...

    This makes sense from a desing perspective. I have a pretty complex object hierarchy and took the easy way out in this particular case. The aggregate root in my case would be an abstract base document class but in most of the concrete object children I need the concrete type. Casting the parent property to the desired type looked like a reasonable compromise.

    Do you know if this is why the property visibility was changed?

  •  01-07-2009, 3:19 PM 29548 in reply to 29439

    Re: Got the new book, got the latest code, got questions...

    The Parent property used to be protected, now it is protected internal. We broadened the scope slightly because it was necessary for some other part of CSLA.


    Rocky
  •  01-08-2009, 10:36 AM 29590 in reply to 29548

    Re: Got the new book, got the latest code, got questions...

    Ok, my mistake. I missunderstood the effect of making the property protected internal.

    Thanks

View as RSS news feed in XML

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems