Inline Temp

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: Basically inline temp is removing variables that have been created to store a value returned from a query and replacing it with the actual query. This leads to much clearer code (arguable)...)
 
(Fixed up formatting)
Line 2: Line 2:
 
This leads to much clearer code (arguable) and less code.
 
This leads to much clearer code (arguable) and less code.
  
boolean payTax(int payRate) {
+
  boolean payTax(int payRate) {
 
       int wages = payRate * hoursWorked;
 
       int wages = payRate * hoursWorked;
 
       return wages >100;
 
       return wages >100;
}
+
  }
  
 
Using inline temp
 
Using inline temp
  
boolean payTax(int payRate) {
+
  boolean payTax(int payRate) {
 
       return (payRate * hoursWorked) >100;
 
       return (payRate * hoursWorked) >100;
}
+
  }

Revision as of 11:59, 13 October 2009

Basically inline temp is removing variables that have been created to store a value returned from a query and replacing it with the actual query. This leads to much clearer code (arguable) and less code.

 boolean payTax(int payRate) {
     int wages = payRate * hoursWorked;
     return wages >100;
 }

Using inline temp

 boolean payTax(int payRate) {
     return (payRate * hoursWorked) >100;
 }
Personal tools