Reduce implicit parameter passing
From CSSEMediaWiki
(Difference between revisions)
Line 1: | Line 1: | ||
− | This rule suggests | + | This rule suggests methods should always use explicit parameters. In some situations, instance variables are treated like global variables and are used as implicit parameters among methods within the same class. Implicit parameters tie methods to the class, and it also hides the necessary information from outsiders who wish to use the method. |
− | The undesired results of using implicit | + | The undesired results of using implicit parameters are |
− | * making difficult to split a class into parts | + | * making it difficult to split a class into parts |
− | * | + | * leading other programmers to misuse methods as they may not be aware of all implicit parameters |
− | + | Changing the implicit parameters to explicit parameters will overcome these problems, although [[Reduce the number of arguments|beware of too many parameters]]. | |
== Example == | == Example == | ||
To do. | To do. | ||
+ | |||
+ | [[Category: Johnson and Foote's heuristics]] |
Revision as of 01:45, 18 August 2009
This rule suggests methods should always use explicit parameters. In some situations, instance variables are treated like global variables and are used as implicit parameters among methods within the same class. Implicit parameters tie methods to the class, and it also hides the necessary information from outsiders who wish to use the method.
The undesired results of using implicit parameters are
- making it difficult to split a class into parts
- leading other programmers to misuse methods as they may not be aware of all implicit parameters
Changing the implicit parameters to explicit parameters will overcome these problems, although beware of too many parameters.
Example
To do.