in reply to Template Method contra passing subroutines to constructor.

I've used both, at different times, and for different reasons.

If a collection of parameterizations that would have been passed as coderefs into a constructor deserve "a life of their own", then the override method makes more sense. You create a named class that contains the code to create this newly-abled object.

So, some objects have instance-specific behavior, while other objects share behavior.

For an interesting way to eliminate the distinction, see the Self language, or look at Perl workalikes like Class::Prototyped.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re: Template Method contra passing subroutines to constructor.