I know the difference between static type and other types but I am not sure which is to used where. Now I am using static types in all places to avoid object instantiation. Is it a good idea to use it that way ? Is there any particular disadvantage in using static type in all places ??
EDIT
What do you call this as static String staff ?
This is an excellent question. Usually you should not use
staticmethods/variables unless you know for sure that it’s a correct application for it. In object oriented programming (OOP), objects encapsulate data and behavior. Typically, *instance methods are used to manipulate the object’s data.Staticmethods/variables should only be used for functionality that is not associated with any particular object. A good example of a valid application forstaticisMath.random().Some notes about instance and static methods/variables:
A good book to read that covers this topic is Clean Code by Robert Martin. Highly recommended.
*instance methods are the opposite of static methods. They are associated with a class instance, instead of the class itself.
Addressing your edit, assuming that that’s a variable, you’d access it like this:
Edit: here’s a post I made on another forum a while back, with some good answers. It’s a PHP forum, but the concepts still apply.
http://forums.devnetwork.net/viewtopic.php?f=1&t=127667