using static methods and classes

Posted by vedant1811 on Programmers See other posts from Programmers or by vedant1811
Published on 2012-07-04T09:04:44Z Indexed on 2012/07/04 9:22 UTC
Read the original article Hit count: 180

I know that static methods/variables are associated with the class and not the objects of the class and are useful in situations when we need to keep count of, say the number of objects of the class that were created. Non-static members on the other hand may need to work on the specific object (i.e. to use the variables initialized by the constructor)

My question what should we do when we need neither of the functionalities?

Say I just need a utility function that accepts value(s) and returns a value besed solely on the values passed. I want to know whether such methods should be static or not. How is programming efficiency affected and which is a better coding practice/convention and why.

PS: I don't want to spark off a debate, I just want a subjective answer and/or references.

© Programmers or respective owner

Related posts about object-oriented

Related posts about programming-practices