forquare1 wrote: I think the term is polymorphism? ComplexStrategy would subclass BasicStrategy and override certain methods. Methods it didn't override would be called from BasicStrategy. Both classes could be made static so they can't be instantiated, or they could be Abstract.
To have a ComplexStrategy instance you would sublass it (adding functionality). If you then called self.sanityCheck(), it would call the one from ComplexStrategy if it existed, if it doesn't exist in ComplexStrategy then it'll be called from BasicStrategy. Even then if you called something like self.isEqual it'll keep going up to NSObject, unless you've overridden it further down the line.
I've a feeling there is another way, I'll check later in my book at home. |