MyMonkName has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am developing a certain application that uses HTML::Template. For each template that it uses, I find that a certain number of options to new() are generally needed, and a certain number of tags are always supplied to param(). So far, I've created a class MyApp::Template that wraps around the methods from HTML::Template that I need (new(), param(), output() &c.) and it seems to be working fine.

If I was starting from scratch, what reasons could there be for trying to inherit/override HTML::Template methods instead?

Replies are listed 'Best First'.
Re: Wrap a method or inherit a method?
by GrandFather (Saint) on Dec 19, 2011 at 00:39 UTC

    If you "wrap" an HTML::Template object in your own object you need to expose all the functionality in HTML::Template that you use by providing wrapper methods in your class. Where you provide some added value that is fine, but if all you are doing is passing a bunch of parameters through to the underlying object then you are simply buying extra work for yourself.

    On the other hand if you derive from HTML::Template you only need provide the added value methods. Everything else is served out of the base class.

    True laziness is hard work