Académique Documents
Professionnel Documents
Culture Documents
Software
Sesión 21 – Previo a PSP 0.1
• Métricas
• Estándar de codificación
Métricas
Métricas
Elenfoque principal de PSP 0.1 es la
métrica del software
Para que las métricas del software sean
útiles deben de ser
Obtenidas para un propósito específico
Definidas explícitamente
Administradas apropiadamente
Usadas apropiadamente
Métricas
El
hecho de medir tu proceso no lo
mejorará por sí solo
100
80
Time (hours)
60
40
20
0
0 5 10 15 20 25 30 35 40 45
Text Pages
Métricas
60
50
Time (hours)
40
30
20
10
0
0 100 200 300 400 500 600 700
Script Size
Métricas
70
60
50
Time (hours)
40
30
20
10
0
0 1000 2000 3000 4000 5000 6000 7000 8000
Report Size
Métricas
100
90
80
70
Time (hours)
60
50
40
30
20
10
0
0 500 1000 1500 2000 2500 3000 3500 4000
Screen Elements
Métricas
6000
5000
4000
Time (min.)
3000
2000
1000
0
0 100 200 300 400 500 600 700 800
C++ LOC
Métricas
14000
12000
10000
Time (min.)
8000
6000
4000
2000
0
0 200 400 600 800 1000 1200 1400 1600 1800 2000
Pascal LOC
Métricas
Cuando 2 personas miden lo mismo, obtendrán el
mismo resultado?
Para ello necesitamos una definición precisa de la
métrica
Diferentes personas podrán tener diferentes
definiciones de elementos de base de datos
LOC de pascal no es igual a LOC de ensamblador
LOC nuevo no es lo mismo que LOC modificado
LOC lógico no es lo mismo que LOC físico
LOC de C++ de una persona no serán los mismos
LOC de C++ de otra persona
Métricas
PSPsugiere medir LOC lógicos en lugar de
LOC físicos
LOC lógicas
Se correlacionan directamente con el
esfuerzo
Únicos
LOC físicos
No reflejan directamente el esfuerzo
Estándar de codificación
Estándar de codificación
Para que el conteo de LOC lógico sea
efectivo, se debe de establecer un
estándar de codificación
El estándar debe de incluir
Conteo de todas las declaraciones
Begin, end, if, else
{,
}, ;
Declaraciones, directivas, encabezados
Estándar de codificación
No contar
Líneas en blanco
Comentarios
Código generado automáticamente
Contar
Código añadido o modificado
Estándar de codificación
Para proyectos pequeños, el conteo
puede ser manual, pero con extremo
cuidado
Para proyectos grandes, el conteo debe
ser automatizado
Para todos los casos, se especifica un
estándar de codificación que debe ser
estrictamente seguido
Estándar de codificación
Este estándar debe de Declaración se
contener los siguientes secciones primarias
elementos
Propósito Espacios en blanco
Formato de Identación
encabezado Empleo de
Listado de contenido mayúsculas
del archivo
Instrucciones de reúso
Declaración de
identificadores
Uso de comentarios
Purpose To guide implementation of C++ programs
Program Headers Begin all programs with a descriptive header.
Header Format /******************************************************************/
/* Program Assignment: the program number */
/* Name: your name */
/* Date: the date you started developing the program */
/* Description: a short description of the program and what it does */
/******************************************************************/
Listing Contents Provide a summary of the listing contents
Contents /******************************************************************/
Example /* Listing Contents: */
/* Reuse instructions */
/* Modification instructions */
/* Compilation instructions */
/* Includes */
/* Class declarations: */
/* CData */
/* ASet */
/* Source code in c:/classes/CData.cpp: */
/* CData */
/* CData() */
/* Empty() */
/******************************************************************/
Reuse - Describe how the program is used: declaration format, parameter values, types,
Instructions and formats.
- Provide warnings of illegal values, overflow conditions, or other conditions that
could potentially result in improper operation.
Reuse Instruction /******************************************************************/
Example /* Reuse instructions */
/* int PrintLine(char *line_of_character) */
/* Purpose: to print string, ‘line_of_character’, on one print line */
/* Limitations: the line length must not exceed LINE_LENGTH */
/* Return 0 if printer not ready to print, else 1 */
/******************************************************************/
Identifiers Use descriptive names for all variable, function names, constants, and other
identifiers. Avoid abbreviations or single-letter variables.
Identifier Int number_of_students; /* This is GOOD */
Example Float: x4, j, ftave; /* This is BAD */
Comments - Document the code so the reader can understand its operation.
- Comments should explain both the purpose and behavior of the code.
- Comment variable declarations to indicate their purpose.
Good Comment If(record_count > limit) /* have all records been processed? */
Bad Comment If(record_count > limit) /* check if record count exceeds limit */
Major Sections Precede major program sections by a block comment that describes the processing
done in the next section.
Example /******************************************************************/
/* The program section examines the contents of the array ‘grades’ and calcu- */
/* lates the average class grade. */
/******************************************************************/
Blank Spaces - Write programs with sufficient spacing so they do not appear crowded.
- Separate every program construct with at least one space.
Indenting - Indent each brace level from the preceding level.
- Open and close braces should be on lines by themselves and aligned.
Indenting while (miss_distance > threshold)
Example {
success_code = move_robot (target _location);
if (success_code == MOVE_FAILED)
{
printf(“The robot move has failed.\n”);
}
}
Capitalization - Capitalize all defines.
- Lowercase all other identifiers and reserved words.
- To make them readable, user messages may use mixed case.
Capitalization #define DEFAULT-NUMBER-OF-STUDENTS 15
Examples int class-size = DEFAULT-NUMBER-OF-STUDENTS;
Tarea
Definir un estándar de codificación de
acuerdo a su lenguaje de programación
Traerlo impreso en el formato especificado
anteriormente
© 2011 Creative Commons
Atribución-NoComercial-Compartir
Igual 2.5 México.
http://creativecommons.org/licenses
/by-nc-sa/2.5/mx/