Reduce the size of methods

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: In general, a small method is a good method. Not only is a small method an easier chunk of logic for a programmer to understand, it makes subclassing easier. Large methods in superclasses ...)
 
Line 1: Line 1:
 
In general, a small method is a good method. Not only is a small method an easier chunk of logic for a programmer to understand, it makes subclassing easier. Large methods in superclasses will often be partly correct for subclasses, but not completely correct. This means that the subclass has to re-write the whole method, even if most of it is correct. If your superclass only has small methods, only some of these methods will need to be changed in the subclass, or more likely, the only change will be adding some more small methods. Small methods are therefor an important part of software reusability.
 
In general, a small method is a good method. Not only is a small method an easier chunk of logic for a programmer to understand, it makes subclassing easier. Large methods in superclasses will often be partly correct for subclasses, but not completely correct. This means that the subclass has to re-write the whole method, even if most of it is correct. If your superclass only has small methods, only some of these methods will need to be changed in the subclass, or more likely, the only change will be adding some more small methods. Small methods are therefor an important part of software reusability.
 +
 +
 +
== See Also ==
 +
* [[Long method smell]]

Revision as of 02:36, 13 August 2008

In general, a small method is a good method. Not only is a small method an easier chunk of logic for a programmer to understand, it makes subclassing easier. Large methods in superclasses will often be partly correct for subclasses, but not completely correct. This means that the subclass has to re-write the whole method, even if most of it is correct. If your superclass only has small methods, only some of these methods will need to be changed in the subclass, or more likely, the only change will be adding some more small methods. Small methods are therefor an important part of software reusability.


See Also

Personal tools