in reply to Re: Re: abstraction - reusing OO module subs
in thread abstraction - reusing OO module subs

It is quite common in OO programming to have the sort of redundancy among methods that you're worried about. It's a natural consequence of the emphasis on encapsulation that you end up with many similar getters and setters (or accessors/mutators) to mediate interaction with variables. To alleviate the tedium some people do things such as write modules like Class::MethodMaker to automate the process.

As for functions vs methods, the main difference is how they are called. A function, once defined or imported into the current namespace, may be called directly by name. In contrast, a method must be called on either a package name or an instance of the package. See Re: Perl Prototypes for a fuller explanation.

  • Comment on Re: Re: Re: abstraction - reusing OO module subs