CodingStyle

From Neuroglia Wiki
Jump to: navigation, search

Indentación[edit]

  if ( condition ) 
     { 
     while ( condition ) 
        { 
        foo(); 
        } 
     }

Naming Convention / Convecion de Nombres[edit]

tipo Ejemplo Notas
Funciones lowerCamelCase
Clases UpperCamelCase
Metodos lowerCamelCase
Variables de una palabra lower
Variables de mas de una Palabra lower_variable
Variables de cantidad qty_
Loop indices
  for ( $i = 0; $i < 5; $i++ )
      { 
      for ( $j = 0; $j < 4; $j++ ) 
          { 
          for ( $k = 0; $k < 3; $k++ ) 
              { 
              for ( $m = 0; $m < 2; $m++ ) 
                  { 
                  foo($i, $j, $k, $m); 
                  } 
              } 
          }
       }
SQL Simple Query
    $sql = "SELECT `id`, `name` FROM `people`
         . "WHERE `name`='Fred' OR `name`='Susan'";

SQL Large Query
    $sql = "SELECT id, 
                   name,
                   last_name,
                   code 
            FROM people
            WHERE name ='Fred' 
            OR    name ='Susan'";