Skip to content

1.1.6 Instructions

Tomaz Martins edited this page Jul 31, 2015 · 2 revisions

1.1.6.1 Simple Instructions

Each line should contain at most one statement.  

1.1.6.2 Instructions Composite

Compound statements are statements that contain lists of statements enclosed in braces {} instructions.

1.1.6.3 Instructions Return

Return instructions should be successful only by variables, except that there is good reason to the contrary.

1.1.6.4 Structure if-else

Statements of if-else must meet the following formats:

if( condition ) {
     /* Write Instructions Here. */
} else {
     /* Write Instructions Here.
      * or
      * Nothing To Do.
      */
}

if( condition ) {
     /* Write Instructions Here. */
} else {
     /* Write Instructions Here. */
} else {
     /* Write Instructions Here.
      * or
      *Nothing To Do.
      */
}

It should be remembered that an instruction if should always use keys and the default behavior (else).

1.1.6.5 Structure for

for statements should follow the following format:

for( int i = 0; i < length; i ++ ) {
     /* Write Instructions Here. */
}

When using the comma operator in the initialization or update clause of a statement for, avoid the complexity of using more than three variables.

1.1.6.6 Structure 'while`

while statements should follow the following format:

while( condition ) {
     /* Write Instructions Here. */
}

1.1.6.7 Structure do-while

Statements do-while should follow the following format:

do {
     /* Write Instructions Here. */
} while( condition )

1.1.6.8 Structure switch

switch statements should follow the following format:

switch( sum ) {
     case 1:
         /* Write Instructions Here. */
     case 2:
         /* Write Instructions Here. */
     case 3:
         /* Write Instructions Here. */
     case 4:
         /* Write Instructions Here. */
     default:
         /* Write Instructions Here. */
}

2.1.6.9 Structure try-catch

try-catch statements should follow the following format:

try {
     /* Write Instructions Here. */
} catch( Exception e ) {
     /* Write Instructions Here. */
}

The instruction try-catch can also be followed by, finally, running regardless of whether or not completed the block successfully try.

try {
     /* Write Instructions Here. */
} catch( Exception e ) {
     /* Write Instructions Here. */
} finally {
     /* Write Instructions Here. */
}