Why should I use an object instance to access member functions rather than class::staticFunction?
( or why not? )
Why should I use an object instance to access member functions rather than class::staticFunction?
( or why not? )
Static members of a class only hold global state. Instances each have their own state.
Because the object contains the variables that the method might act on.
If you don't use this facility, you are not using OOP (Object Oriented Programming), you are using perl modules.
On the other hand, sometimes what you propose–just using static functions–is appropriate.
You're allowed to use the object.function() notation for a static function, but I'd advise against it -- it gives the misleading impression that the function is associated with the specific object, like with a non-static member function. Using the classname::function() syntax portrays the situation clearly and accurately.
instance methods belong to a single instance/object to which state/variables they have access.
static methods belong to a whole class and no specific instance/object and do not have access to any instance members. They only can use other static members.