when to make a method static

Posted by Don on Stack Overflow See other posts from Stack Overflow or by Don
Published on 2010-04-26T13:05:05Z Indexed on 2010/04/26 13:13 UTC
Read the original article Hit count: 198

Hi,

I'd like to know how people decide whether to define a method as static. I'm aware that a method can only be defined as static if it doesn't require access to instance fields. So lets say we have a method that does not access instance fields, do you always define such a method as static, or only if you need to call it statically (without a reference to an instance).

Perhaps another way of asking the same question, is whether you use static or non-static as the default?

Thanks, Don

© Stack Overflow or respective owner

Related posts about object-oriented

Related posts about language-agnostic