Posted by terence.parker on 08/22/06 08:15
I'm writing a bunch of classes (specifically, for parsing) but have a
question about class inheritance.
I understand that with textbook object orientation, a class
extension/inheritance represents "a type of" ... like a carrot being a
'type of vegetable'. However, in my case there is no such association :
I am making a class for parsing and extending it to another class
called Alert.
'Alert' is not a type of 'Parser', but because I want to share some of
the functions/variables defined in Parser I decided inheritance was the
best way to achieve this. I don't particularly want to re-instantiate
Parser inside of Alert, nor do I want to redo things such as MySQL
connections.
Someone told me that a solution is to pass in my 'Parser' object to the
new Alert instance ... but is this better?
Or should I just ignore what the textbook says and do what is easiest
for me... or is there another method i'm overlooking?
Thanks!
Terence
[Back to original message]
|