通过getModel调用函数vs直接通过对象调用

In Magento if we want to call function from model then we prefer to use Mage::getModel('moduleName/className')->functionName(); but we can also achieve it directly using Namespace_ModuleName_Model_ClassName::FunctionName();

I know as per Magento we have to use getModel but I checked someone used direct Php method to call function and said "This was preferred against the Mage::getModel way due to the fact that we won’t need to instantiate the whole model for one simple array. If we would use the Mage::getModel expression, the model will first need to instantiate (executing its constructor) before executing the “functionname” method, which only returns an array and does not have complex logic. This way it’s way faster and it also limit the logic executed to return the steps array."

Please suggest which will be the preferable way to use and advantage/disadvantage of using direct calling function.

If you are calling a method like this: Namespace_ModuleName_Model_ClassName::FunctionName(), then you are assuming this is a static method. Only static methods can be called like this.

See here for a good write-up on when to use static methods. The idea is that static methods are stateless, and do not need the context of an object in order to run. In this case, it's true that you do not need to instantiate the object, as static methods should not call instance methods, so they don't make use of the $this keyword.

In Magento, things are a bit different, in that getModel gives you a very important feature: class rewrites.

If you do Mage::getModel('moduleName/className'), Magento resolves this name to a PHP class using it's class rewrites from config.xml. This means that you can rewrite a core or community class in your local namespace, and Magento will use your class everywhere in the code, in place of the old one.

Keeping this in mind, you can easily see a drawback of using static methods and calling them directly: you will not be able to rewrite them!

Your only 'clean' solution if you want to modify code in static methods is to copy the entire file in app/code/local/Original/Module; doing this many times will make upgrades difficult.