Re: Implementing optional methods in a concrete class, but calling themfrom an abstract class.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux