Talk:Overloading
From CSSEMediaWiki
(Difference between revisions)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Lukas Korsika) |
|||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
I disagree with this. I think method overloading can make code easier to read, as long as the overloaded methods perform the same basic task. | I disagree with this. I think method overloading can make code easier to read, as long as the overloaded methods perform the same basic task. | ||
Two areas where it might be useful to overload methods is having default parameters to customise the functionality of the method (for instance, calculateMetrics might have an additional bool specifying whether to compute the extra, CPU intensive metrics which are only sometimes needed). | Two areas where it might be useful to overload methods is having default parameters to customise the functionality of the method (for instance, calculateMetrics might have an additional bool specifying whether to compute the extra, CPU intensive metrics which are only sometimes needed). |
Latest revision as of 03:11, 25 November 2010
I disagree with this. I think method overloading can make code easier to read, as long as the overloaded methods perform the same basic task. Two areas where it might be useful to overload methods is having default parameters to customise the functionality of the method (for instance, calculateMetrics might have an additional bool specifying whether to compute the extra, CPU intensive metrics which are only sometimes needed). Another time when it might be useful is for different types. If you have a applyMagicFormula(float) method, it might make sense to overload it for ints, to reduce casting.
What do people think? --Lukas Korsika 01:53, 21 October 2010 (UTC)