dash2 has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a little set of modules to provide services for distributed computing/P2P networks. I want the modules to be as abstract as possible - they should be useful for different message formats and transports, although they have their own default format and transport.
There are 2 ways to achieve this:
1. Write a superclass with default methods for sending, receiving, encoding and decoding messages, and let subclasses override these methods. This is used by e.g. IO::Socket and HTTP::Daemon.
2. Write a class with optional callback hooks for the above tasks. Unless the hooks are defined (as subrefs) by the client, use the default methods. Something like this method is used by e.g. WWW::Robot.
Has anyone got any opinions on which is better, and when?
David
dave hj~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: subclass or hooks?
by dragonchild (Archbishop) on Nov 21, 2001 at 00:15 UTC | |
by tye (Sage) on Nov 21, 2001 at 02:02 UTC | |
by fokat (Deacon) on Nov 21, 2001 at 03:07 UTC | |
by tilly (Archbishop) on Nov 22, 2001 at 00:02 UTC |