Introduce Explaining Variable

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
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("MAC") > -1) &&
+
  if ( (platform.toUpperCase().indexOf(&quot;MAC&quot;) &gt; -1) &amp;&amp;
  (browser.toUpperCase().indexOf("IE") > -1) &&
+
  (browser.toUpperCase().indexOf(&quot;IE&quot;) &gt; -1) &amp;&amp;
  wasInitialized() && resize > 0 )
+
  wasInitialized() &amp;&amp; resize &gt; 0 )
 
  {
 
  {
 
   // do something
 
   // do something
 
  }
 
  }
  
  final boolean isMacOs    = platform.toUpperCase().indexOf("MAC") > -1;<br>
+
  final boolean isMacOs    = platform.toUpperCase().indexOf(&quot;MAC&quot;) &gt; -1;&lt;br&gt;
  final boolean isIEBrowser = browser.toUpperCase().indexOf("IE"> -1;<br>
+
  final boolean isIEBrowser = browser.toUpperCase().indexOf(&quot;IE&quot;&gt; -1;&lt;br&gt;
  final boolean wasResized  = resize > 0;<br><br>
+
  final boolean wasResized  = resize &gt; 0;&lt;br&gt;&lt;br&gt;
  if (isMacOs && isIEBrowser && wasInitialized() && wasResized)
+
  if (isMacOs &amp;&amp; isIEBrowser &amp;&amp; wasInitialized() &amp;&amp; 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
}
Personal tools