From: Hugh Sasse Staff Elec Eng Date: 2003-12-10T04:52:20+09:00 Subject: Re: Inheriting variables, super, and "not super"? On Wed, 10 Dec 2003, David A. Black wrote: > Hi -- > > On Wed, 10 Dec 2003, Hugh Sasse Staff Elec Eng wrote: > > > Is there a way in a method to say > > "ignore this if called as super"? > > > > I am trying to inherit variables from a superclass, but I may need > > them different in the subclass, so I can't use class variables. > > Might you make use of instance variables of the classes themselves? > That might be a cleaner way to preserve state on a per-Class basis. That's what I was thinking originally, but... > (I don't know whether it fits in with the whole picture though.) > > > Instance variables are not passed on to subclasses, so to initialize > > them I need to call super within initialize... ... they are not handed down to the children. Maybe I shold be using accessor methods in the parent, which the child will inherit, and I can constrain the access. > > > > Also, at present, some of my initialization code sets up other > > things which make sense for an instance of that class, but not when [...] > > I have a feeling that if you're looking at two classes whose objects > have such different needs, it may be that the case for having one of > them be a subclass of the other is not all that strong. The child classes respond to the same events as the ancestors, so this is where the idea of inheritance is worth hanging on to, so ave code duplication. > > Do you think a module-centered design would work better? You could > un-verticalize (?) the structure, and bring in what each class or even > each object needs. It is a nested structure except where the states need to mess with other objects (GUI). I could include the parent to acheive this I suppose. I think navigating this hierarchy will probably have about the same complexity as I have now... I'll give this more thought. Thank you. > > David > Hugh