Helper methods, static vs. instance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Memory usage wise is it a good idea to specify methods in utility/helper
classes as instance methods rather than static methods?

Rasika.
 
Rasika said:
Memory usage wise is it a good idea to specify methods in utility/helper
classes as instance methods rather than static methods?

Quite the opposite - it would mean you'd have to create an instance in
order to use the methods.

However, memory shouldn't usually be your prime concern. Think about it
in terms of object orientation - do these methods logically operate on
an instance? If so, they should probably be instance methods. If not,
they should probably be static methods. Helper classes almost always
just have static methods.
 
Thank you!

Jon Skeet said:
Quite the opposite - it would mean you'd have to create an instance in
order to use the methods.

However, memory shouldn't usually be your prime concern. Think about it
in terms of object orientation - do these methods logically operate on
an instance? If so, they should probably be instance methods. If not,
they should probably be static methods. Helper classes almost always
just have static methods.
 
Back
Top