As it is clear from question, if I convert a normal method to static what gains will I made?
You will gain clarity, because static
makes it clear that the method doesn’t depend on an object state. You will also facilitate reusability because static
methods may be used in more contexts (i.e. when you don’t have an instance of the class).
In general, it’s not really a question of gain, it’s a question of semantics: does your method depend on the object state? If so, make it non-static
. In all other cases, make it static
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With