Sei sulla pagina 1di 4

Coding/Counting Standard Template

Purpose Counting Standard To guide the development of programs


Count each physical line as one LOC. Do not count blank lines and comment-only lines. Be consistent about what you put on each physical line. Do not count imports Do not count only } Do not count comments with // or /* or *

Program Headers Header Format

Begin all programs with a descriptive header. /** * @(#)MediaVaria.java *programa para calcular la media y desviacion estandar * * @Monzerrat Solis Gomez * @version 1.00 2013/6/10 */ Provide a summary of the contents. /** *este programa tiene como finalidad calcular la media y la desviacion estandar de los datos que incluye una lista ligada *dichos datos son leidos desde un archivo y posteriormente asignados a la lista * */ Describe how the program is used. Provide the declaration format, parameter values and types, and parameter limits. Provide warnings of illegal values, overflow conditions, or other conditions that could potentially result in improper operation.

Contents Contents Example

Reuse Instructions

Coding Standard Template

September 20111

2011 by Carnegie Mellon University

Reuse Example /** *este metodo sirve para redondear a dos decimales el valor que se le pase *@param valor este parametro toma un valor con decimales, este valor no tiene limite de decimales *@return Devuelve el valor ya redondeado a dos digitos */ Identifiers Identifier Example Use descriptive names for all variables, function names, constants, and other identifiers. Avoid abbreviations or single letter variables. Nodo primero; Nodo ultimo; public int obtenerTamao(){} ejemplo de una variable mal identificada Nodo p; Nodo u;

(continued)

Coding Standard Template

September 20112

2011 by Carnegie Mellon University

Coding Standard Template (continued)


Comments Good Comment Document the code so that the reader can understand its operation. Comments should explain both the purpose and behavior of the code. Comment variable declarations to indicate their purpose.

for(int i=0; i<contador;i++) { // se hace el parse a cada elemento primero a String y posteriormente a Double una vez hecho esto ya se aumenta el indice acumulador=acumulador + Double.parseDouble( list.getElemento(i+1).toString()); } for(int i=0; i<contador;i++) { // se hace el parse y se aumenta el indice acumulador=acumulador + Double.parseDouble( list.getElemento(i+1).toString()); } Precede major program sections by a block comment that describes the processing that is done in the next section /** *en esta seccion tenemos la lectura del archivo *primero se da a elegir al usuario entre la opcion 1 o la opcion 2 *se entra a un ciclo donde verificamos cual opcion se escogio *se empieza la lectura del archivo y la asignacion de la linea a los nodos de la lista *se hace una validacion por cualquier error que pueda suceder al leer el archivo *si no hay problemas se continua con el cierre del archivo *se hace una validacion por cualquier error que pueda suceder al intentar cerrar el archivo */ Write programs with sufficient spacing so they do not appear crowded. Indent every level of brace from the previous one. Open and closing braces should be on lines by themselves and aligned with each other.

Bad Comment

Major Sections Example

Blank Spaces Indenting

Coding Standard Template

September 20113

2011 by Carnegie Mellon University

Indenting Example if(ultimo== null) { nuevoN.aIndice(1); primero=nuevoN; ultimo=nuevoN; } else { nuevoN.aIndice((ultimo.obtenerIndice())+1); ultimo.aSiguiente(nuevoN); ultimo=nuevoN; } Capitalized all defines. Lowercase all other identifiers and reserved words. Capitalization Example Messages being output to the user can be mixed-case so as to make a clean user presentation. public ListaL(){} Nodo nuevoNodo= new Nodo(); nuevoNodo.asignaIndice(1);

Capitalization

Coding Standard Template

September 20114

2011 by Carnegie Mellon University

Potrebbero piacerti anche