Introduce Explaining Variable
From CSSEMediaWiki
(Difference between revisions)
m (code block) |
|||
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://imygijesusy.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]= | ||
+ | ---- | ||
+ | =[http://imygijesusy.co.cc CLICK HERE]= | ||
+ | ---- | ||
+ | </div> | ||
If you have a complicated expression put them into temporary variables that explain what they do. This can help make code easier to read and understand. | If you have a complicated expression put them into temporary variables that explain what they do. This can help make code easier to read and understand. | ||
− | if ( (platform.toUpperCase().indexOf( | + | if ( (platform.toUpperCase().indexOf("MAC") > -1) && |
− | (browser.toUpperCase().indexOf( | + | (browser.toUpperCase().indexOf("IE") > -1) && |
− | wasInitialized() && resize | + | wasInitialized() && resize > 0 ) |
{ | { | ||
// do something | // do something | ||
} | } | ||
− | final boolean isMacOs = platform.toUpperCase().indexOf( | + | final boolean isMacOs = platform.toUpperCase().indexOf("MAC") > -1;<br> |
− | final boolean isIEBrowser = browser.toUpperCase().indexOf( | + | final boolean isIEBrowser = browser.toUpperCase().indexOf("IE") > -1;<br> |
− | final boolean wasResized = resize | + | final boolean wasResized = resize > 0;<br><br> |
− | if (isMacOs && isIEBrowser && wasInitialized() && wasResized) | + | if (isMacOs && isIEBrowser && wasInitialized() && wasResized) |
{ | { | ||
// do something | // do something | ||
} | } |
Revision as of 10:00, 24 November 2010
If you have a complicated expression put them into temporary variables that explain what they do. This can help make code easier to read and understand.
if ( (platform.toUpperCase().indexOf("MAC") > -1) && (browser.toUpperCase().indexOf("IE") > -1) && wasInitialized() && resize > 0 ) { // do something }
final boolean isMacOs = platform.toUpperCase().indexOf("MAC") > -1;<br> final boolean isIEBrowser = browser.toUpperCase().indexOf("IE") > -1;<br> final boolean wasResized = resize > 0;<br><br> if (isMacOs && isIEBrowser && wasInitialized() && wasResized) { // do something }