View Single Post
  #8  
Old 03-30-2007, 06:57 AM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Umm what?
PHP Code:
  function whatever(hi,hi) {
     if(
this==that) {
        
blah;
        
blah
        
if(true)
           
cool;
     } elseif(
yourmom) {
        
stuff;
        
morestuff;
     } else 
somethingcoolhere;
  } 
Looks way nicer then

PHP Code:
function whatever(hi,hi)
{
  if (
this==that
  {
    
blah;
    
blah
    
if(true)
      
cool;
  }
  elseif (
yourmom
  {
    
stuff;
    
morestuff;
  } 
  else
  {
    
somethingcoolhere;
  }

But that is a preference thing. I personally think what you say is better looks more obnoxious.

also, you space too much, you can use spacing to help visualize order of operations. and padding the conditional statements is a waste.

PHP Code:
something/somethingelse*3;
something y^3;
= ( (x1-x2)^+ (y1-y2)^)^.5;
if(
trueis better then if( true )
if(
== yis better then if( == 
also, single line functions are okay as wrappers. Declare them at the top, looks nice.
PHP Code:
//dont know why you would ever need to wrap showimg but an example
function onShowImg(ind,img,ix,iyshowimg(ind,img,ix,iy);

function 
whatever() {
  
stuffhappens;
  
scheduleEvent(5,"ShowImg",201,"possums.png",x+2,y+1);

And i am going to agree with dusty on multilining if statements. if it needs to be that obnoxious, store booleans before the comparision.
__________________
Reply With Quote