Vibrant discussion about CSLA .NET and using the framework to build great business applications.
In this case I would define 2 separate objects for the 2 scenarios.
Your business and validation logic will likely be different and the objects
will be less complex than trying to do this as one object.
Sent: Thursday, November 12, 2009 11:30 AM
Subject: [CSLA .NET] Object hierarchy
I look through many of the discussions here about switchable objects, but I
still didn't find the solution for my problem. Right now I'm reading the 2008
edition of the book, and several years ago I read the 2005 edition, and I build
one project with CSLA 2.7 two years ago.
Still, the concept of Parent and Child objects is probably the most confusing
part to me.
My case is like this:
I should build a ShoppingCart object, which will have Products collection with
many Product object. Each Product will contain other business objects as
properties, but this is not what concerns me.
What I'm still didn't quite get, is how to implement the Product object?
On one hand, it is part of a ShoppingCart, and as such it should be declared as
child object - probably the parent will be a Products collection which will be
the child of the ShoppingCart object.
On the other hand, when I'm adding new product to the system, it is not part of
any ShoppingCart yet and it is definitely a parent object! Only after the
Product is added in the system, it eventually can became part of some
ShoppingCart object, but this is not a requirement, but only a possibility.
So, after read all the answers here, I get to the point when as I see it, I
have two options:
Am I getting it right, or am I completely wrong?
I will highly appreciate any comments on that!
P.S. If something is not clear, p lease let me know so I can explain it.