Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualwodinoneeye

Posted 19 August 2013 - 07:01 AM


The one I dislike is the start btrace at the end of the if test and the 
other hanging out by itself at the end of the block




if (x & y & funcz(a)) {
// do shirt here
}
My usual syntax Ive used :


if (x & y & funcz(a))
   {
   //do shirt here   --- note triple blank indent
   }

when its not a single statement in the if-true code block



I will do    if ()     plus single statement (and align them).... when they are simple


if      (x < 0 )        x = 0;
else if (x > maxx)      x = maxx;
if      (y < 0 )        y = 0;
else if ( y > maxy)     y = maxy;



I also add extra blanks  in many places to make the code less of a run together clustercluck and even split and align if clauses
(funny I usually dont do some for simple 'for'  control clauses)


if ((test1() == 3)    &&
    (test2() == 4)    &&
    (test3() == 7))
   {
   // do shirt
   }


Im also liberal adding blank lines particularly around For loops to accentuate their groupings


comments I dont mind being on the same line as code


for (o=0; o<maxi; o++)     // loop thru all objects
   {
   object[o].x = tx;
   object[o].y = ty;
   // etc....
   }


Ive rarely ever use the   ? :     statement form as they disappear in clutter making it hard to visually scan code 


//-------------------------------------------------------------------------

and I use lines like this between EVERY function definition to help spot the startpoints (again speeds up visually scanning code )

#3wodinoneeye

Posted 19 August 2013 - 06:57 AM


The one I dislike is the start btrace at the end of the if test and the 
other hanging out by itself at the end of the block




if (x & y & funcz(a)) {
// do shirt here
}

My usual sysntax Ive used :

 

 

if (x & y & funcz(a))

   {

   //do shirt here   --- note triple blank indent

   }

 

when its not a single statement in the if-true code block

 

 

 

I will do    if ()     plus single statement (and align them).... when they are simple

 

 

if         (x < 0 )          x = 0;

else if (x > maxx)      x = maxx;

if         (y < 0 )          y = 0;

else if ( y > maxy)     y = maxy;

 

 

 

I also add extra blanks  in many places to make the code less of a run together clustercluck and even split and align if clauses

(funny I usually dont do some for simple 'for'  control clauses)

 

 

if ((test1 == 3)      &&

    (test2() == 4)    &&

    (test3() == 7))

   {

   // do shirt

   }

 

 

Im also liberal adding blank lines particularly around For loops to accentuate their groupings

 

 

comments I dont mind being on the same line as code

 

 

for (o=0; o<maxi; o++)     // loop thru all objects

   {

   object[o].x = tx;

   object[o].y = ty;

   // etc....

   }

 

 

Ive rarely ever use the   ? :     statement form as they disappear in clutter making it hard to visually scan code 

 

 

//-------------------------------------------------------------------------

 

and I use lines like this between EVERY function definition to help spot the startpoints (again speeds up visually scanning code )


#2wodinoneeye

Posted 19 August 2013 - 06:55 AM


The one I dislike is the start btrace at the end of the if test and the 
other hanging out by itself at the end of the block




if (x & y & funcz(a)) {
// do shirt here
}

My usual sysntax Ive used :

 

 

if (x & y & funcz(a))

   {

   //do shirt here   --- note triple blank indent

   }

 

when its not a single statement in the if-true code block

 

 

 

I will do    if ()     plus single statement (and align them).... when they are simple

 

 

if         (x < 0 )          x = 0;

else if (x > maxx)      x = maxx;

if         (y < 0 )          y = 0;

else if ( y > maxy)     y = maxy;

 

 

 

I also add extra blanks  in many places to make the code less of a run together clustercluck and even split and align if clauses

(funny I usually dont do some for simple 'for'  control clauses)

 

 

if ((test1 == 3)      &&

    (test2() == 4)    &&

    (test3() == 7))

   {

   // do shirt

   }

 

 

Im also liberal adding blank lines particularly around For loops to accentuate their groupings

 

 

comments I dont mind being on the same line as code

 

 

for (o=0; o<maxi; o++)     // loop thru all objects

   {

   object[o].x = tx;

   object[o].y = ty;

   // etc....

   }

 

 

Ive rarely ever use the   ? :     statedment form as they disappear in clutter making it hard to visually scan code 

 

 

//-------------------------------------------------------------------------

 

and I use lines like this between EVERY function definition to help spot the startpoints (again speeds up visually scanning code )


#1wodinoneeye

Posted 19 August 2013 - 06:47 AM


The one I dislike is the start btrace at the end of the if test and the 
other hanging out by itself at the end of the block




if (x & y & funcz(a)) {
// do shirt here
}

My usual sysntax Ive used :

 

 

if (x & y & funcz(a))

   {

   //do shirt here

   }

 

when its not a single statement in the if-true code block

 

 

 

I will do    if ()     plus single statement (and align them).... when they are simple

 

 

I also add extra blanks  in many places to make the code less of a run together clustercluck and even split and align if clauses

 

 

if ((test1 == 3)      &&

    (test2() == 4)    &&

    (test3() == 7))

   {

   // do shirt

   }

 

 

 

Ive rarely ever use the   ? :     statedment form as they disappear in clutter making it hard to visually scan code 

 

 

 


PARTNERS