Re: Implementing optional methods in a concrete class, but calling themfrom an abstract class.
| From: | Nathan Rixham | Date: | Tue, 02 Nov 2010 10:49:08 +0000 |
| Subject: | Re: Implementing optional methods in a concrete class, but calling themfrom an abstract class. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309230@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
Hi. I have an abstract base class (call it genericServiceHandler). I have concrete classes (FaxService, EmailService). ... What would you all do?If you've got fixed logic then just add all the onStart onPause and similar methods to the abstract class, stub them to accept the correct params but simply return immediately, call them in the correct places with $this->onStart($arg0...) Then any class which extends it, like EmailService, can simply overwrite which ever methods it needs to implement. The other approach which can be nice is to decouple it and go for an event or message based system, that way you can hook in multiple different callbacks to "do something" when the onSomething [event/message] is dispatched. Best, Nathan