perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Peters <>
Subject Re: Class method or Object method?
Date Thu, 29 Jan 2009 18:04:10 GMT
kropotkin wrote:

> In general is it better to use a class method or object method?

It depends on what you're using it for and how. Does the method act on any instance specific
data? Or does it act on class specific data?

A more concrete example would be a Dog class. Is bark() a method on Dog or $fido? Well, every
no matter it's name is going to bark the same. Is eat() a method on Dog or $fido? Well, if
changes $fido's next_poop_interval property, then obviously it needs to be an instance method.

And of course, if your system is only every going to have 1 Dog then you don't need to ever
instances, right?

Michael Peters
Plus Three, LP

View raw message