SlideShare a Scribd company logo
DEFECT PREVENTION SOFTWARE
• Tools for static analysis of source code: PMD Marker,
FindBugs, Metrics Marker
• Tools for determining software quality metrics for source
code: VizzMaintenance
• Tools for UML design critics: ArgoUML
• Tools for generating test cases from UML model of your code:
Smartesting
See static analysis report sample and software quality metrics
for sample class on following pages…
Here is sample CommaHyphenString.java source code
1 /**
2 *
3 * CommaHyphenString parses .properties file. It eliminates commas or low lines
4 * from .properties file so items in it( such as categories) could be properly
5 * showed on screen
6 */
7 import java.util.*;
8
9 public class CommaHyphenString {
10
11 //String s;
12 int lastIndex;
13 CommaHyphenString(){}
14
15
16 /** Eliminates commas, returns array of strings with low line
17 * @return String[]
18 */
19 String[] getWithLowLine(String s) {
20 int lastIndex = defineLast(s);
21 if(lastIndex==0){
22 String[] ss = new String[1];
23 ss[0] = s;
24 return ss;
25 } else {
26 int start = -1;
27 Vector v = new Vector();
28 int current = s.indexOf(',');
29 do {
30 v.addElement(s.substring(start+1,current));
31 start = current;
32 current = s.indexOf(',',current+1);
33 } while (start!=lastIndex);
34
35 String[] ss = new String[v.size()+1];
36 for(int i=0; i<v.size(); i++){
37 ss[i] = (String)v.elementAt(i);
38 }
39 ss[v.size()] = s.substring(lastIndex+1,s.length());
40 return ss;
41 }
42 }
43
44 /** Eliminates low line
45 * @return String[]
46 */
47 String[] getStringsOnly(String s){
48 String[] temp = this.getWithLowLine(s);
49 for (int i=0; i<temp.length; i++){
50 char[] tempChar = temp[i].toCharArray();
51 String k = "";
52 for (int j=0; j<tempChar.length; j++){
53 if(tempChar[j]=='_') tempChar[j]=' ';
54 k+=tempChar[j];
55 }
56 temp[i] = k;
57 }
58 return temp;
59 }
60
61
62 /** Returns categories with low line
63 * @return String[]
64 */
65 String[] getCategoriesHyphen(String s){
66 return this.getWithLowLine(s);
67 }
68
69 /** Returns categories
70 * @return String[]
71 */
72 String[] getCategories(String s){
73 return this.getStringsOnly(s);
74 }
75
76 /** Defines index of last comma in string
77 * @return integer
78 */
79 public int defineLast(String s){
80 int lastIndex = 0;
81 char c[] = s.toCharArray();
82 for (int i=0; i<c.length; i++){
83 if(c[i]==',') lastIndex=i;
84 }
85 return lastIndex;
86 }
87
88 }
Here are static analysis violations detected in CommaHyphenString.java
Description of static analysis violation Line Tool
All classes and interfaces must belong to a named package 9 PMD Marker
Unused field: CommaHyphenString.lastIndex 12 FindBugs
Use explicit scoping instead of the default package private level 12 PMD Marker
Document empty constructor 13 PMD Marker
Lines of Code in Method is 27 16
Metrics
Marker
Number of Statements is 28 16
Metrics
Marker
Avoid variables with short names like s 19 PMD Marker
Parameter 's' is not assigned and could be declared final 19 PMD Marker
Use explicit scoping instead of the default package private level 19 PMD Marker
Local variable 'lastIndex' could be declared final 20 PMD Marker
Avoid variables with short names like ss 22 PMD Marker
A method should have only one exit point, and that should be the last statement in the
method 24 PMD Marker
Avoid variables with short names like v 27 PMD Marker
Consider replacing this Vector with the newer java.util.List 27 PMD Marker
Local variable 'v' could be declared final 27 PMD Marker
Use ArrayList instead of Vector 27 PMD Marker
Avoid variables with short names like ss 35 PMD Marker
Lines of Code in Method is 16 44
Metrics
Marker
Avoid variables with short names like s 47 PMD Marker
Parameter 's' is not assigned and could be declared final 47 PMD Marker
Use explicit scoping instead of the default package private level 47 PMD Marker
Avoid using if statements without curly braces 53 PMD Marker
CommaHyphenString.getStringsOnly(String) concatenates strings using + in a loop 54 FindBugs
Prefer StringBuffer over += for concatenating strings 54 PMD Marker
Parameter 's' is not assigned and could be declared final 65 PMD Marker
Use explicit scoping instead of the default package private level 65 PMD Marker
Parameter 's' is not assigned and could be declared final 72 PMD Marker
Use explicit scoping instead of the default package private level 72 PMD Marker
Parameter 's' is not assigned and could be declared final 79 PMD Marker
Local variable 'c' could be declared final 81 PMD Marker
Avoid using if statements without curly braces 83 PMD Marker
Here are VizzMaintenance software quality metrics for CommaHyphenString.java class
Class Name Maintainability CBO CYC_Classes DAC DIT ILCOM LCOM LD LEN LOC LOD_Class MPC NAM NOC NOM
CommaHyphenString 0,136637872 0 1 0 0 0 25 0 17 80 0,167 0 6 0 5
Here are full names of VizzMaintenance software quality metrics (click on links for details)
Complexity
o Size
 Lines of Code (LOC)
o Interface Complexity
 Number of Attributes and Methods (SIZE2)
 Number Of local Methods (NOM)
o Structural Complexity
 McCabe Cyclomatic Complexity (CC)
 Weighted Method Count (WMC)
 Response For a Class (RFC)
Architecture and Structure
o Inheritance
 Depth of Inheritance Tree (DIT)
 Number Of Children (NOC)
o Coupling
o Afferent Coupling (Ca)
 Coupling Between Objects (CBO)
 Change Dependency Between Classes (CDBC)
 Change Dependency Of Classes (CDOC)
 Efferent Coupling (Ce)
 Coupling Factor (CF)
 Data Abstraction Coupling (DAC)
 Instability (I)
 Locality of Data (LD)
 Message Passing Coupling (MPC)
 Package Data Abstraction Coupling (PDAC)
o Cohesion
 Lack of Cohesion in Methods (LCOM)
 Improvement of LCOM (ILCOM)
 Tight Class Cohesion (TCC)
Design Guidelines and Code Conventions
o Documentation
 Lack Of Documentation (LOD)
o Code Conventions
Follow me on Facebook page
https://www.facebook.com/AutomatedTesting

More Related Content

PPTX
Virtual function
PDF
Swift cooking course making a cake ... pattern
PPT
PPT
PDF
ENKI: Access Control for Encrypted Query Processing
PPTX
Opengl lec 3
PDF
Algorithm and Programming (Procedure and Function)
PPTX
System verilog coverage
Virtual function
Swift cooking course making a cake ... pattern
ENKI: Access Control for Encrypted Query Processing
Opengl lec 3
Algorithm and Programming (Procedure and Function)
System verilog coverage

What's hot (20)

PDF
Realizing Fine-Grained and Flexible Access Control to Outsourced Data with At...
PDF
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
PPTX
Polymorphism
PDF
DBMask: Fine-Grained Access Control on Encrypted Relational Databases
PPT
Dcom vs. corba
PPT
Refactoring - improving the smell of your code
PPT
Scala functions
PDF
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
PDF
EKON 12 Closures Coding
PDF
Implicit conversion and parameters
PPT
Algorithmic Notations
PPTX
Theory of Computation Unit 4
PPTX
PPT ON VHDL subprogram,package,alias,use,generate and concurrent statments an...
PDF
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
PPSX
DIWE - Programming with JavaScript
PPTX
Advanced programming topics asma
PPTX
09. Methods
PPT
pointers, virtual functions and polymorphisms in c++ || in cpp
PDF
Privacy-Preserving Multi-Keyword Fuzzy Search over Encrypted Data in the Cloud
PPT
Constructors and destructors in C++ part 2
Realizing Fine-Grained and Flexible Access Control to Outsourced Data with At...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Polymorphism
DBMask: Fine-Grained Access Control on Encrypted Relational Databases
Dcom vs. corba
Refactoring - improving the smell of your code
Scala functions
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
EKON 12 Closures Coding
Implicit conversion and parameters
Algorithmic Notations
Theory of Computation Unit 4
PPT ON VHDL subprogram,package,alias,use,generate and concurrent statments an...
(chapter 3) A Concise and Practical Introduction to Programming Algorithms in...
DIWE - Programming with JavaScript
Advanced programming topics asma
09. Methods
pointers, virtual functions and polymorphisms in c++ || in cpp
Privacy-Preserving Multi-Keyword Fuzzy Search over Encrypted Data in the Cloud
Constructors and destructors in C++ part 2
Ad

Viewers also liked (8)

PDF
Checking code-with-pmd
PDF
Exercise E Answers Examples
PPTX
Basic quality tools and others
PPT
091 Process Mapping
PPTX
The Challenge of Accepting Software
PPT
HCI 3e - Ch 7: Design rules
PDF
Software Development Life Cycle (SDLC)
PPT
THE RTI ACT 2005 PRESENTATION
Checking code-with-pmd
Exercise E Answers Examples
Basic quality tools and others
091 Process Mapping
The Challenge of Accepting Software
HCI 3e - Ch 7: Design rules
Software Development Life Cycle (SDLC)
THE RTI ACT 2005 PRESENTATION
Ad

Similar to Defect prevention software (20)

PPTX
Static analysis: Around Java in 60 minutes
PPTX
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
PPTX
Static code analysis: what? how? why?
PDF
Code Quality Assurance with PMD (2004)
ODT
Android Open source coading guidel ine
PPTX
Java Code Quality Tools
PPSX
Coding standard
PDF
Measuring Code Quality in WTF/min.
PDF
Measuring code quality:WTF/min by @dgomezg
PDF
Eclipse Indigo DemoCamp Walldorf 2011
DOC
VizzMaintenance Eclipse Plugin Metrics
PPTX
Coding standards for java
PDF
Source Code Quality
PDF
Android coding standard
PPTX
Java best practices
PDF
Wtf per lineofcode
PDF
Clean code
PPTX
R. herves. clean code (theme)2
PDF
Clean Code 2
PPT
Writing Good Code
Static analysis: Around Java in 60 minutes
EVERYTHING ABOUT STATIC CODE ANALYSIS FOR A JAVA PROGRAMMER
Static code analysis: what? how? why?
Code Quality Assurance with PMD (2004)
Android Open source coading guidel ine
Java Code Quality Tools
Coding standard
Measuring Code Quality in WTF/min.
Measuring code quality:WTF/min by @dgomezg
Eclipse Indigo DemoCamp Walldorf 2011
VizzMaintenance Eclipse Plugin Metrics
Coding standards for java
Source Code Quality
Android coding standard
Java best practices
Wtf per lineofcode
Clean code
R. herves. clean code (theme)2
Clean Code 2
Writing Good Code

More from Zarko Acimovic (6)

PDF
Metrics for example Java project
PDF
Elevator pitch for testing software architecture and software design
PDF
Software defect prevention example project
PDF
Example of-non-cohesive-methods
PDF
Example of-method-with-cyclomatic-complexity-202
PDF
Example of-method-with-cyclomatic-complexity-17
Metrics for example Java project
Elevator pitch for testing software architecture and software design
Software defect prevention example project
Example of-non-cohesive-methods
Example of-method-with-cyclomatic-complexity-202
Example of-method-with-cyclomatic-complexity-17

Recently uploaded (20)

PDF
August Patch Tuesday
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
1. Introduction to Computer Programming.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Mushroom cultivation and it's methods.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Tartificialntelligence_presentation.pptx
August Patch Tuesday
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
NewMind AI Weekly Chronicles - August'25-Week II
1. Introduction to Computer Programming.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Getting Started with Data Integration: FME Form 101
Group 1 Presentation -Planning and Decision Making .pptx
Mushroom cultivation and it's methods.pdf
Encapsulation theory and applications.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Hindi spoken digit analysis for native and non-native speakers
TLE Review Electricity (Electricity).pptx
SOPHOS-XG Firewall Administrator PPT.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A comparative study of natural language inference in Swahili using monolingua...
cloud_computing_Infrastucture_as_cloud_p
Tartificialntelligence_presentation.pptx

Defect prevention software

  • 1. DEFECT PREVENTION SOFTWARE • Tools for static analysis of source code: PMD Marker, FindBugs, Metrics Marker • Tools for determining software quality metrics for source code: VizzMaintenance • Tools for UML design critics: ArgoUML • Tools for generating test cases from UML model of your code: Smartesting See static analysis report sample and software quality metrics for sample class on following pages…
  • 2. Here is sample CommaHyphenString.java source code 1 /** 2 * 3 * CommaHyphenString parses .properties file. It eliminates commas or low lines 4 * from .properties file so items in it( such as categories) could be properly 5 * showed on screen 6 */ 7 import java.util.*; 8 9 public class CommaHyphenString { 10 11 //String s; 12 int lastIndex; 13 CommaHyphenString(){} 14 15 16 /** Eliminates commas, returns array of strings with low line 17 * @return String[] 18 */ 19 String[] getWithLowLine(String s) { 20 int lastIndex = defineLast(s); 21 if(lastIndex==0){ 22 String[] ss = new String[1]; 23 ss[0] = s; 24 return ss; 25 } else { 26 int start = -1; 27 Vector v = new Vector(); 28 int current = s.indexOf(','); 29 do { 30 v.addElement(s.substring(start+1,current)); 31 start = current; 32 current = s.indexOf(',',current+1); 33 } while (start!=lastIndex); 34 35 String[] ss = new String[v.size()+1]; 36 for(int i=0; i<v.size(); i++){ 37 ss[i] = (String)v.elementAt(i); 38 }
  • 3. 39 ss[v.size()] = s.substring(lastIndex+1,s.length()); 40 return ss; 41 } 42 } 43 44 /** Eliminates low line 45 * @return String[] 46 */ 47 String[] getStringsOnly(String s){ 48 String[] temp = this.getWithLowLine(s); 49 for (int i=0; i<temp.length; i++){ 50 char[] tempChar = temp[i].toCharArray(); 51 String k = ""; 52 for (int j=0; j<tempChar.length; j++){ 53 if(tempChar[j]=='_') tempChar[j]=' '; 54 k+=tempChar[j]; 55 } 56 temp[i] = k; 57 } 58 return temp; 59 } 60 61 62 /** Returns categories with low line 63 * @return String[] 64 */ 65 String[] getCategoriesHyphen(String s){ 66 return this.getWithLowLine(s); 67 } 68 69 /** Returns categories 70 * @return String[] 71 */ 72 String[] getCategories(String s){ 73 return this.getStringsOnly(s); 74 } 75 76 /** Defines index of last comma in string 77 * @return integer 78 */
  • 4. 79 public int defineLast(String s){ 80 int lastIndex = 0; 81 char c[] = s.toCharArray(); 82 for (int i=0; i<c.length; i++){ 83 if(c[i]==',') lastIndex=i; 84 } 85 return lastIndex; 86 } 87 88 } Here are static analysis violations detected in CommaHyphenString.java Description of static analysis violation Line Tool All classes and interfaces must belong to a named package 9 PMD Marker Unused field: CommaHyphenString.lastIndex 12 FindBugs Use explicit scoping instead of the default package private level 12 PMD Marker Document empty constructor 13 PMD Marker Lines of Code in Method is 27 16 Metrics Marker Number of Statements is 28 16 Metrics Marker Avoid variables with short names like s 19 PMD Marker Parameter 's' is not assigned and could be declared final 19 PMD Marker Use explicit scoping instead of the default package private level 19 PMD Marker Local variable 'lastIndex' could be declared final 20 PMD Marker Avoid variables with short names like ss 22 PMD Marker A method should have only one exit point, and that should be the last statement in the method 24 PMD Marker Avoid variables with short names like v 27 PMD Marker Consider replacing this Vector with the newer java.util.List 27 PMD Marker Local variable 'v' could be declared final 27 PMD Marker Use ArrayList instead of Vector 27 PMD Marker Avoid variables with short names like ss 35 PMD Marker Lines of Code in Method is 16 44 Metrics Marker Avoid variables with short names like s 47 PMD Marker
  • 5. Parameter 's' is not assigned and could be declared final 47 PMD Marker Use explicit scoping instead of the default package private level 47 PMD Marker Avoid using if statements without curly braces 53 PMD Marker CommaHyphenString.getStringsOnly(String) concatenates strings using + in a loop 54 FindBugs Prefer StringBuffer over += for concatenating strings 54 PMD Marker Parameter 's' is not assigned and could be declared final 65 PMD Marker Use explicit scoping instead of the default package private level 65 PMD Marker Parameter 's' is not assigned and could be declared final 72 PMD Marker Use explicit scoping instead of the default package private level 72 PMD Marker Parameter 's' is not assigned and could be declared final 79 PMD Marker Local variable 'c' could be declared final 81 PMD Marker Avoid using if statements without curly braces 83 PMD Marker Here are VizzMaintenance software quality metrics for CommaHyphenString.java class Class Name Maintainability CBO CYC_Classes DAC DIT ILCOM LCOM LD LEN LOC LOD_Class MPC NAM NOC NOM CommaHyphenString 0,136637872 0 1 0 0 0 25 0 17 80 0,167 0 6 0 5
  • 6. Here are full names of VizzMaintenance software quality metrics (click on links for details) Complexity o Size  Lines of Code (LOC) o Interface Complexity  Number of Attributes and Methods (SIZE2)  Number Of local Methods (NOM) o Structural Complexity  McCabe Cyclomatic Complexity (CC)  Weighted Method Count (WMC)  Response For a Class (RFC) Architecture and Structure o Inheritance  Depth of Inheritance Tree (DIT)  Number Of Children (NOC) o Coupling o Afferent Coupling (Ca)
  • 7.  Coupling Between Objects (CBO)  Change Dependency Between Classes (CDBC)  Change Dependency Of Classes (CDOC)  Efferent Coupling (Ce)  Coupling Factor (CF)  Data Abstraction Coupling (DAC)  Instability (I)  Locality of Data (LD)  Message Passing Coupling (MPC)  Package Data Abstraction Coupling (PDAC) o Cohesion  Lack of Cohesion in Methods (LCOM)  Improvement of LCOM (ILCOM)  Tight Class Cohesion (TCC) Design Guidelines and Code Conventions o Documentation  Lack Of Documentation (LOD) o Code Conventions
  • 8. Follow me on Facebook page https://www.facebook.com/AutomatedTesting