Reduce implicit parameter passing

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
This rule suggests method should always use explicit parameters. In some situation, global variables are used as implicit parameter among methods within the same class. Implicit parameter ties methods with the class, and it also hide the necessary information for outsiders who wish to use the method.  
+
This rule suggests method should always use explicit parameters. In some situation, global variables are used as implicit parameters among methods within the same class. Implicit parameter ties methods with the class, and it also hide the necessary information for outsiders who wish to use the method.  
  
 
The undesired results of using implicit parameter are  
 
The undesired results of using implicit parameter are  
 
* making difficult to split a class into parts, or  
 
* making difficult to split a class into parts, or  
 
* even possible to lead other programmers to miuse method (since parameters are implicit passed in which case may not be awared by other programmers).
 
* even possible to lead other programmers to miuse method (since parameters are implicit passed in which case may not be awared by other programmers).
 +
 +
Change the implicit parameter to explicit parameter will overcome these problems.

Revision as of 11:31, 12 August 2008

This rule suggests method should always use explicit parameters. In some situation, global variables are used as implicit parameters among methods within the same class. Implicit parameter ties methods with the class, and it also hide the necessary information for outsiders who wish to use the method.

The undesired results of using implicit parameter are

  • making difficult to split a class into parts, or
  • even possible to lead other programmers to miuse method (since parameters are implicit passed in which case may not be awared by other programmers).

Change the implicit parameter to explicit parameter will overcome these problems.

Personal tools