Shared property for list of objects requires 3 classes?

Shared property for list of objects requires 3 classes?

Old forum URL: forums.lhotka.net/forums/t/5916.aspx


rsbaker0 posted on Monday, December 01, 2008

Before I go down this road once again I want to be sure this the correct practice.

I have a list of objects that I want to have access to a common, updatable value. (e.g. an editable property). In theory, I could directly implement the property in the list class, but none of the CSLA infrastructure would support it.

So, I have to put said property in a BusinessBase derived class, so this means I need 3 classes:

1. Root object (BusinessBase object to hold common property)

2. ...List Class (BusinessListBase of objects)

3. ......Child object class (BusinessBase-derived child object)

Is this correct? (or is it acceptable to implement shared data in the list class itself, without the CSLA support?)

ajj3085 replied on Tuesday, December 02, 2008

I think this is more of a matter of what databinding will let you do.  In WinForms, if you were to bind your BLB object toa  binding list, I'm not sure you'd get properties off the list object itself; I think you'd only see properties of the objects in the list. 

To answer your question though, your best bet is to have the root object with child BLB.  That's a known pattern, where if you try the other route you're outside what people here usually do, so you might have a harder time getting help if something doesn't work right.

rsbaker0 replied on Tuesday, December 02, 2008

Ok, thanks. I thought this was the case but wanted to be sure.

Somehow my sensibilities get mildly offended by the root + BLB because the data the child wants is actually stored in its "grandparent", and CSLA didn't seem to make this easy to get to (at least until recently), but I'll stick with this pattern.

Copyright (c) Marimer LLC