Replace Temp with Query
From CSSEMediaWiki
(Difference between revisions)
Line 1: | Line 1: | ||
+ | ---- | ||
+ | <div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | ||
+ | ---- | ||
+ | =[http://uvetysudema.co.cc Under Construction! Please Visit Reserve Page. Page Will Be Available Shortly]= | ||
+ | ---- | ||
+ | =[http://uvetysudema.co.cc CLICK HERE]= | ||
+ | ---- | ||
+ | </div> | ||
Replace a temp variable with a method call. This makes the variable accessible to other parts of the program. It also allows you to write shorter methods as temp values are only locally available to use you must write all the code related to the temp variable within its scope. I have on many times required a variable outside of its scope and made it global- just straight bad and lazy. -Paul Williams | Replace a temp variable with a method call. This makes the variable accessible to other parts of the program. It also allows you to write shorter methods as temp values are only locally available to use you must write all the code related to the temp variable within its scope. I have on many times required a variable outside of its scope and made it global- just straight bad and lazy. -Paul Williams | ||
double basePrice = _quantity * _itemPrice; | double basePrice = _quantity * _itemPrice; | ||
− | if (basePrice | + | if (basePrice > 1000) |
return basePrice * 0.95; | return basePrice * 0.95; | ||
else | else | ||
Line 10: | Line 18: | ||
Change to | Change to | ||
− | if (basePrice( ) | + | if (basePrice( ) > 1000) |
return basePrice() * 0.95; | return basePrice() * 0.95; | ||
else | else |
Revision as of 10:02, 24 November 2010
Replace a temp variable with a method call. This makes the variable accessible to other parts of the program. It also allows you to write shorter methods as temp values are only locally available to use you must write all the code related to the temp variable within its scope. I have on many times required a variable outside of its scope and made it global- just straight bad and lazy. -Paul Williams
double basePrice = _quantity * _itemPrice; if (basePrice > 1000) return basePrice * 0.95; else return basePrice * 0.98;
Change to
if (basePrice( ) > 1000) return basePrice() * 0.95; else return basePrice( ) * 0.98; ... double basePrice( ) { return _quantity * _itemPrice; }