Inheritance is simpler and quicker but breaks pretty quickly when you want a "plugin" style application. Composition/delegation, where each piece can be implemented by a separate class if necessary and the implementation to use can be read from a config file or something, gives you a much more scalable plugin API. It requires some thinking up front though, and is overkill if you will not actually need to support plugins.
Middle ground? Not really. You could start with inheritance and split things out when you need to support plugins, I suppose. It depends on the way the app will be developed in the future, e.g. if you want CPAN authors to be able to add functionality without bugging you, a composition approach is much better.
In reply to Re: Class or Object composition ??
by perrin
in thread Class or Object composition ??
by rootcho
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |