You are here: Proper object extension convention « PHP Programming Language « IT news, forums, messages
Proper object extension convention

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация