Object Design Question

Object Design Question

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


mikeclimbs posted on Thursday, January 11, 2007

I have an object called contacts that contains name and address info, that can be a vendor or client that links to a vendor or client table based on its type(Vendor or Client).

I'm not sure if I should create one contact object with 2 child properties. or 2 objects that inherit from contacts.

I was leaning towards 2 objects that inherit from contacts.

Any guidance would be appreciated.

Thanks

Mike

 

RockfordLhotka replied on Thursday, January 11, 2007

To get the most out of CSLA .NET you should consider focusing your object design on what the objects do rather than on what they contain.

What you've described thus far is merely data, which doesn't give enough information to recommend a good approach for an object design. The real question is what are these objects for? What do they do?

To answer those questions you need a use case. Objects don't exist in a vaccuum, nor do they exist at the application level. They exist at the use case level - they exist to fill a specific role within the context of a specific sequence of actions that make up that use case.

Odds are you have a couple use cases: enter/edit vendor and enter/edit client. These two different use cases should have two different sets of objects. Using inheritance to get reuse should only occur to get reuse of behavior, not properties (which are really just data). Using inheritance to reuse data/properties merely couples use cases together where they should not be coupled, and the result is typically a hard to maintain system.

mikeclimbs replied on Friday, January 12, 2007

Rocky,

Thanks for your help. It makes sense to treat them as seperate objects.  Thinking about the specail validation cases would be difficult to maintain.

Mike

Copyright (c) Marimer LLC