Confirmation on a property (tightly coupling) and initialisation - I am reading the book :-)

Confirmation on a property (tightly coupling) and initialisation - I am reading the book :-)

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


ianinspain posted on Thursday, March 01, 2007

Hi there,

I hope someone can give me some input, i am close but i have been following the book and everything fits into place just about but I came across 2 questions, heres an outline.

I have been creating one of EditableBusinessBase classes, working good. I basically have private variables like

Guid _id;
string _propertyName = string.empty;
int _plotSize;

Do i need to initialise _plotSize to a number? I know i have to with strings, as it states in the book because it doesn't bind if its null but what about a number?

Then my other question is with regards to a property on a businessBase class. I have various public properties (get/set) like this which show the contents of the private members like _id, _propertyName etc etc

public string PropertyName
{
    get {....}
.
.

All fine and now i need another property (get/set) that will be "Property Type" which will contain things like "house", "office", "farm house", "land", "apartment" etc.. so I presume i need to create another BusinessEditableBase for property types this i am ok with... but then how do i create the property on my original EditableBase class above, i could put

private MyNewEditableBase.PropertyTypes _propertyTypes; // But this is tightly coupled isn't it?

public MyNewEditableBase.PropertyTypes PropertyTypes
{
   get{ ..}
.
.

But this would tightly couple the 2 objects wouldn't it?? And the other question that i keep thinking about when reading other parts of Rocky's book is that yes i do need a EditableBase for this propertyType as i need to Edit / Add records but i presume when I will use it from another BussinessObject then I would use a ReadOnlyList as it acting like an ENUM - is this correct?

I don't think i need some kind of Assignment type object like in the csla.net book as its only a 1 to 1 relationship... It is a real estate(property) record and one the of fields/properties on the object will be of a type "MyNewEditableBase" o similar.

As you can see, I am a little lost, can anyone give me a little input.

Thanks in advance

Ian

ianinspain replied on Thursday, March 01, 2007

I thought i also might put this comment here to ensure i have explained it correctly.

In simple terms if this "PropertyType" (real estate type) could be of type enum i.e.

enum
{
house,
apartment,
office
}

but of course it something that isn't fixed so it needs to work with the framework to allow the options that are available to PropertyType to be updated etc

I hope i have explained it well enough for someone to jump in and give a little feedback..

Thanks once again

ian

RockfordLhotka replied on Thursday, March 01, 2007

You can have an editable root directly contain an editable child, that is fine. The property in the editable root that allows access to the child should be a read-only property, because you don't want the UI to change that reference, only gain access to the child object.

The idea of containment (or aggregation) is at the core of object-oriented design. Objects contain other objects all the time, this is not a bad thing. In fact, it is a way to express important relationships between objects.

In most cases this is not a form of tight coupling. The root object is aware of its child, but probably won't interact with it very much. The child object may be entirely unaware of its parent.

Regarding your list of property types, this is the purpose behind NameValueListBase. You can use NVLB to create an object that represents a list of name/value pairs, typically loaded from the database or a configuration file.

ianinspain replied on Thursday, March 08, 2007

Wow Rocky!, the penny just dropped... reading over the book again and your explanations has really hit the point.... Thanks for the explanations.... i was so close but was missing that little bit of confirmation..

Thanks once again!

I am sure i will be back later with the odd few questions, things are really moving now..

Cheers

Ian

Copyright (c) Marimer LLC