in reply to Class or Object composition ??
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Class or Object composition ??
by bsb (Priest) on Oct 03, 2006 at 23:21 UTC | |
by perrin (Chancellor) on Oct 04, 2006 at 18:52 UTC |