perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Peters <mpet...@plusthree.com>
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
state 
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
dog, 
no matter it's name is going to bark the same. Is eat() a method on Dog or $fido? Well, if
eat() 
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
have 
instances, right?

-- 
Michael Peters
Plus Three, LP


Mime
View raw message