Hi
I'm sitting here making a method in a object. The method doesn't really require instatiation of the object, and then i started wondering.... is this correct, and what is the best way to call this method?
meaning:
This method could actually be a global function (what it does can be used in other conjuctions) but I'm not really planning to use the function in other context than the specific object.
Now, when i have to call it in my code. Which is faster? calling it from the instantiated object? like
[CODE=php]
<?php
$object->method($parame ter);
?>
[/CODE]
or should i treat it in a more abstract manner like
[CODE=php]
<?php
$object::method ($paremeter);
?>
[/CODE]
Personally I'd say use the instantiated object, but is it a matter of coding style or is there a really good reason why to prefer one over the other? (as I'm sure there is)
I'm sitting here making a method in a object. The method doesn't really require instatiation of the object, and then i started wondering.... is this correct, and what is the best way to call this method?
meaning:
This method could actually be a global function (what it does can be used in other conjuctions) but I'm not really planning to use the function in other context than the specific object.
Now, when i have to call it in my code. Which is faster? calling it from the instantiated object? like
[CODE=php]
<?php
$object->method($parame ter);
?>
[/CODE]
or should i treat it in a more abstract manner like
[CODE=php]
<?php
$object::method ($paremeter);
?>
[/CODE]
Personally I'd say use the instantiated object, but is it a matter of coding style or is there a really good reason why to prefer one over the other? (as I'm sure there is)
Comment