Escolar Documentos
Profissional Documentos
Cultura Documentos
Rules vs guidelines
Guidelines
any guide or indication of a future course of action: guidelines on the government's future policy. a principle put forward to set standards or determine a course of action
Rule
a principle or regulation governing conduct, action, procedure, arrangement, An authoritative, prescribed direction for conduct
Why guidelines
Practical programming in c
From 1980 to 1990, the average number of lines in a typical application went from 23,000 to 1,200,000. The average system age went from 4.75 to 9.4 years. What's worse, 74% of the managers surveyed at the 1990 Annual Meeting and Conference of the Software Maintenance Association reported that they "have systems in their department, that have to be maintained by specific individuals because no one else understands thems.
Why guidelines
90% of the time the documentation is lost. Of the remaining 10%, 9% of the time the revision of the documentation is different from the revision of the program and therefore completely useless. The 1% of the time you actually have documentation and the correct revision of the documentation, the information will be written in Chinese.
Metric
Quality metric
Lines of code Cyclomatic complexity Halstead Complexity
or
number of enclosed areas + 1 In this case, V(G) = 4
Clycomatic complexity
howComplex() { int i=20; while (i<10) { System.out.printf("i is %d", i); if (i%2 == 0) { System.out.println("even"); } else { System.out.println("odd"); } } }
Cylco continue
Cyclomatic complexity gives the number of tests, which for a multiway decision statement is the number of decision branches
Visual
A printed page should be no more than 80 columns. Number of statements in a file should not exceed 1000 (thumb-rule, but Compiler dependent) and the number of lines 2000. Number of statements in a function should not exceed 100 (thumb-rule, but Compiler dependent) in a function and the number of lines 200.
Lines of code
Only one statement should exist per line. Avoid use of numeric values (Magic Numbers) in code; use symbolic values instead. Use a space before and after a binary operator (for e.g. in C use - if ( value == 0 ) and not - if ( value==0 ) ). Inaccessible code should be avoided. Care should be taken when using GOTO or return statement. Multiple assignments are not recommended. e.g. a=b=c ; Maximum 4 Levels of Control Structure Nesting : Nesting of statements, "if", "for", "while", etc., should go no more than 4 levels. If more levels appear to be needed, consider use of a function at one of the higher levels .
107
84