Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inheritance-specialization of attributes

Status
Not open for further replies.

jrmartinezb

Programmer
Mar 14, 2003
1
MX
Ive been looking for patterns trying to solve this problem but have found none so far

C1 has an atribute a1 of type C3
C2 is a subclass of C1

BUT:

Attribute a1 in a1 should alwasys belong to class C4, wich is a subclass of C3.

(eg all clsCars have clsWheels, but clsRaceCars have clsWideWheels)

This seems like a fairly common modeling scenario, but I havent found an approach that makes me feel entirely comfortable. My only solution so far is to throw an exception if an attempt is made to set the value of an attribute to something other that what is allowed

Thanks in advance

PS

Pardon my english, not my language.

 
C1 should be abstract

then...

C2 defines accessor/mutator methods for a1 that enforce type of C4

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top