You are on page 1of 229

Software Defect Prevention Techniques ~ Example Project ~

Zarko Acimovic
Copyright 2013 Zarko Acimovic All rights reserved. ISBN-10: 1481113305 ISBN-13: 978-1481113304

DEDICATION
I dedicate this book to my parents, Ivana and Goran

CONTENTS
1 2 3 4 5 6 7 8 Introduction Theoretical Foundations for Defect Prevention Automatic Tools for Defect Prevention Tools for Defect Prevention in Java Software Development Sample Project Software Requirements Source Code with Violations Design Defects Detected by ArgoUML Examples of Design Defects in Sample Project About the Author 1 24 25 25 26 192 196

Zarko Acimovic

1 INTRODUCTION
I present 5000 lines of Java source code mostly written by using trial/error code/test technique. The code was written for prototype project in three months without using defect prevention techniques ( that is, tools such as PMD, FindBugs, StateOfFlow or ArgoUML) I wrote the code in 2004 and ever since had several business offers to commercialize it which I resisted due to complexity of the code. 8 years after completing project I run the defect prevention tools against the code and uncovered 1123 code violations (almost 1 violation per 5 lines of code) and 121 software design violations. All these violations are presented in book with references to the source code lines where they live. It's worth mentioning that these violations are not defects being present at the code, they just make it easier for you to make mistake when maintaining code or implementing new feature. I recommend readers to use these tools during development and correct all violations on the fly, or switch to some other risk-free programming language such as Haskell, Erlang or Lisp.

2 THEORETICAL FOUNDATIONS FOR DEFECT PREVENTION


Below are the details of E-learning course Software Engineering from IIT Bombay India >> NPTEL >> Courses >> Computer Science and Engineering >> Software Engineering (Video). My opinion is that this course provides solid theoretical foundation for applying software defect prevention techniques. The course can be found on following location http://nptel.iitm.ac.in/video.php?subjectId=106101061 Here is high level overview of the course: 1 - Introduction to Software Engineering (52:21) 2 - Introduction to Software Engineering (52:55) 3 - Overview of Phases (57:22) 4 - Overview of Phases (57:03) 5 - Requirements Engineering / Specification (56:39) 6 - Formal Specification (51:44) 7 - Algebraic Specification Methods (57:34) 8 - Systems Modeling Overview (59:38) 9 - Process Modeling - DFD , Function Decomp (56:28) 10 - Process Modeling - DFD, Function Decomp (53:23) 11 - Data Modeling - ER Diagrams, Mapping (1:00:55) 12 - Data Modeling - ER Diagrams, Mapping (58:08) 13 - Production Quality Software - Introduction (53:04) 14 - Software Design - Primary Consideration (1:04:43) 15 - Design Patterns (56:13) 16 - Class and Component Level Design (54:34)

iv

Software Defects Prevention Techniques Example Project

17 - Architectural Design (59:28) 18 - Software Testing - I (55:39) 19 - Software Testing - II (51:18) 20 - Structural Programming and Some implementation (45:05) 21 - Software Metrics and Quality (54:51) 22 - Verification and Validation (52:43) 23 - Case Study (54:55) 24 - Case Study (58:39) 25 - Software Evolution (55:41) 26 - Agile Development (55:33) 27 - Software Reuse (53:43) 28 - Reuse Continued (57:07) 29 - Introduction to Project Management (52:36) 30 - Project Scope Management (1:08:45) 31 - Project Time Management (56:51) 32 - Estimation - I (51:42) 33 - Estimation - II (50:38) 34 - Project Quality Management (58:32) 35 - Quality Management Systems - I (54:43) 36 - Quality Management Systems (54:53) 37 - Project Configuration Management (53:00) 38 - Project Risk Management (56:04) 39 - Other PM Processes (55:41) Here are the details of the videos: 1. Introduction to Software Engineering (52:21) http://nptel.iitm.ac.in/video.php?subjectId=106101061 2. Introduction to Software Engineering (52:55) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Waterfall Model for Development Deliverables in Waterfall Model Cost/Effort Distribution Shortcomings of Waterfall Model Prototyping Model Prototyping Limitations of Prototyping Iterative Development Spiral Model Project Management Process Project Planning Project Monitoring and Control

Zarko Acimovic

3. Overview of Phases in Software Development (57:22) http://nptel.iitm.ac.in/video.php?subjectId=106101061 4. Overview of Phases in Software Development (57:03) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Structured Analysis Structured Methodology Requirement Specification Format System Design Alternatives Design goals System Architecture Structure Chart Structure Chart Notation OO Approach Design Document Format Detailed Design Implementation Phase Operations & Maintenance Summary

5. Requirements Engineering / Specification (56:39) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Objectives Requirements engineering What is a requirement? Requirements abstraction (Davis) Types of requirement Requirements Audience Functional and non-functional requirements Functional requirements The LIBSYS system Examples of functional requirements Requirements imprecision Requirements completeness and consistency Non-functional requirements Non-functional classifications Non-functional requirement types Non-functional requirements examples Goals and requirements Examples User requirements Problems with natural language LIBSYS requirement Editor grid requirement
vi

Software Defects Prevention Techniques Example Project

Requirement problems Structured presentation Guidelines for writing requirements System requirements Requirements and design Alternatives to NL specification Structured language specifications Form-based specifications Tabular specification Graphical models PDL interface description The requirements document IEEE requirements standard

6. Formal Specification (51:44) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Natural Language Requirement Specification Problem Statement The Need for Formal Specification Formal methods Acceptance of formal methods Use of formal methods Specification in the software process Specification techniques Formal specification languages Use formal specification Development costs with formal specification Properties of Formal Specifications Library Example-Informal Statement Library Example -- Formalization Library Example -- Formalization - 2 Library Example -- Prove Correctness Specification Types Interface specification Sub-system interfaces Behavioral specification Key points

7. Algebraic Specification Methods (57:34) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Disadvantages of NL specifications Another Perspective - Dangers of Physical Representations in Analysis Towards Abstraction What does a Abstract Data Type (ADT) consist of?7:29 What about Post Conditions?
vii

Zarko Acimovic

Algebraic Manipulation using Axioms Abstract Math to Concrete realizations ADTs and Information Hiding Completeness of Specification Definition: sufficient completeness ADT Consistency

8. Systems Modeling Overview (59:38) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Model types Context models The context of an ATM system Process models Behavioral models Order processing DFD Microwave oven model Microwave oven state description Microwave oven stimuli Microwave oven state description Microwave oven stimuli Microwave oven operation Semantic data models Library semantic model Data Dictionary Entries Object models Inheritance models Multiple inheritance Object aggregation Object behavior modeling Structured methods

9. Process Modeling - DFD , Function Decomposition (56:28) http://nptel.iitm.ac.in/video.php?subjectId=106101061 ER MODEL ENTITY ENTITY SET ATTRIBUTE DOMAIN PRIMARY KEYS EXAMPLE : A COLLEGE RELATIONSHIP RELATIONSHIP SET DEPICTING A RELATIONSHIP PRIMARY KEY FOR REPATIONSHIPS RELATIONSHIP CARDINALITY

viii

Software Defects Prevention Techniques Example Project

10. Process Modeling - DFD, Function Decomposition (53:23) http://nptel.iitm.ac.in/video.php?subjectId=106101061 RELATIONSHIP CARDINALITY EXISTENCE DEPENDENCE TERNARY RELATIONSHIPS WEAK ENTITY EXTENDED E-R MODEL Generalization

11. Data Modeling - ER Diagrams, Mapping (1:00:55) Generalization Specialization Inheritance Aggregation Process Model Function Decomposition FD Diagrams: Examples

12. Data Modeling - ER Diagrams, Mapping (58:08) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Data Flow Diagram (DFD) DFD Notation Context Diagram Process Refinement Physical DFD Showing Boundaries DFD Example 1: Payroll DFD Example 2: Old Car Mart DFD Example Old Car Mart Example 3: Book Supplier Book Supplier: Exploding Process 2 Book Supplier : homework

13. Production Quality Software - Introduction (53:04) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Software construction then and now Software Crisis (Late 1980s) More perspective on the Software Crisis Brian Russell's Laws of Software Relativity Properties of Failing software Common Error in Managing the Process
ix

Zarko Acimovic

Software Maintenance Quality Factors for Software Quality Factors Quality Factors - contd. Quality Factors Keys to achieving Structural Quality What ls Abstraction? Abstraction Abstraction Techniques Encapsulation Modules Desirable Characteristics - Weak Coupling Information Hiding Protocol Vs Behavior IH and Abstraction Factorization and Specialization Inclusion Benefits of Inheritance Uses for inheritance

14. Software Design - Primary Consideration (1:04:43) http://nptel.iitm.ac.in/video.php?subjectId=106101061 What's Design? Example Designs in Real Life Programs Example Designs in Real Life Design in Software Engineering Examples of Process Design What is covered in Product Design? From Analysis to Design Factors To be considered in Design Factors to be considered in Design Process of Complex System Design Top-down Vs. Bottom-up Approach Decomposition Composition/Interconnection Basic Principles To be applied during design Abstraction Example Abstractions Describing Abstractions Encapsulation Refinement Refinement and Change Process Communication Other Kinds of Communication

Software Defects Prevention Techniques Example Project

15. Design Patterns (56:13) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Reuse in Software Engineering Patterns in Software Engineering Design Patterns Describing a Design Pattern Pattern Description Template provided by Classification of Patterns Examples of Creational Patterns Behavioral Patterns A Problem The Solution The Design Pattern: Prototype Singleton Pattern Implementing Singleton Adapter Pattern Composite Pattern The Solution Instance Structure for an Instance of a Composite Class The Composite Pattern The Facade Pattern How to interact with components with a subsystem? The Facade Pattern Proxy Pattern: A Mechanic for Communication Real object and Proxy object are different The Proxy Pattern The Decorator Pattern: Object Diagram Visual Component The Template Method Pattern Strategy Pattern

16. Class and Component Level Design (54:34) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Class Example Classes Kinds of Classes Levels of Abstraction Beck and Cunningham's CRC Method CRC: our recommendation A system decomposed in CRCs Contributions of CRC Bertrand Meyer' Design-by-Contract Design by Contact Method Contracts An Example Contact for class Book A Contact Specification

xi

Zarko Acimovic

Class Design Part-Whole Design Odell's Classification Criteria Component-Integral Object Material-Object (made of) Portion-Object Place-Area Member-Bunch Member-Partnership Non-aggregation relations Transitivity in Part-Whole Two Kinds of Part-whole Relations in UML Designing New Subclasses From Old: Inheritance Use of Inheritance in a Subclass Components Use of Inheritance in a Subclass Components Design of Components Decisions about component's non-functional properties Reuse in Component Technologies

17. Architectural Design (59:28) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Software Architecture Why Do We need Architecture? Basic Principles applied by Architects Several Approaches to Architecture The Zachman Framework Open Distributed Processing Reference Model (ODP-RM) ODP: Enterprise viewpoint ODP: Information viewpoint ODP: Computational viewpoint ODP: Computation viewpoint ODP: Engineering viewpoint ODP: Transparencies ODP: Transparencies Defined 4+1 View Model Unified Process Model of Architecture Commonly occurring Architectural Patterns Layers Peers Client-server Pipelines Transactional Flows Filters Blankboards

xii

Software Defects Prevention Techniques Example Project

Facade Broker MVC Microkernel Framework Architectures A Framework References/Readings

18. Software Testing - I (55:39) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Why Testing? A Test Case What criteria to use? Black Box Testing White Box Testing Levels of Testing Stub Modules Test Drivers Test Drivers during Partial Integration Testing Modules with Top Down Integration Testing Modules with Bottom Up Integration Regression Testing Monitoring Behavior of Programs Documentation Probes Standard Error Probes and Exceptions (user defined) Assertions for defensive programming Different Types of Assertions IS the output of a test correct? Test Objectives Alpha testing and Beta testing Debugging Testing In Software Development

19. Software Testing - II (51:18) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Black box vs. white box testing Black Box Testing (External) White Box Testing (Internal) Statement Coverage An Example for Statement Coverage Observations An Example for Statement Coverage Observations Implicit statements
xiii

Zarko Acimovic

Basic Path Testing A Sequential Composition A Branching Statement A While Statement A Repeat Statement A Switch Case Statement A Compound Condition Cyclomatic Complexity Cyclomatic Complexity Example Condition Testing Condition Testing Strategies Data Flow Testing Strategies Exercise: Try different strategies on the below program

20. Structural Programming and Some implementation (45:05) http://nptel.iitm.ac.in/video.php?subjectId=106101061 21. Software Metrics and Quality (54:51) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Why Measurement? Use of Software Measurement The attributes that can be captured Which one is a good measure? What to measure in software? Measurement Scales Ordinal Scale Interval Scale Ratio Scale Absolute Scale Size Metrics Length Functionality Complexity Measuring Structure Coupling and cohesion Object Oriented Metrics: CK and MOOD Quality Guidelines for Coding and Development Defensive Programming for Modules, Functions, Procedures, Classes Preconditions Invariants Use of Software Measurement Separate Compilation Makefile Separate Compilation
xiv

Software Defects Prevention Techniques Example Project

Makefile A Sample Makefile Code organization Development Some good practices

22. Verification and Validation (52:43) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Verification vs validation The V & V process V & V goals V & V confidence Static and dynamic verification Program testing Types of testing Testing and debugging The debugging process V & V planning V-model of development The Structure of a software test plan Software inspections Inspection success Inspections testing Program inspections Inspection pre-conditions Inspection procedure Inspection Roles Inspection Checklists (2) Inspection Checklists (3) Inspection rate Automated static analysis Static Analysis Checks Stages of static analysis LINT static analysis Verification and formal methods Arguments for formal methods

23. Case Study (54:55) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Case study: library book circulation system BOOK CIRCULATION STATEMENT OF PROJECT SCOPE AND OBJECTIVES THE FEASIBILITY STUDY: CIRCULATION Financial analysis for alternatives 1 : Alternatives 2 Plan for alternatives 1
xv

Zarko Acimovic

Feasibility ... Requirements Analysis Circulation System Draw first level DFD Requirements Analysis

24. Case Study (58:39) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Requirements Analysis... Refinement of issue process Requirements Analysis... Requirements Specification... SRS ... System Design: CIRCULATION System Design ... System Design E-R DIAGRAM System Design ... Table Design Physical DB Design Physical DB Design... Physical DB Design... System Design ... Software Architecture Software Architecture... Implementation Schedule Implementation Schedule... Design documentation Detailed Design Data and Module Specification Module ... Implementation

25. Software Evolution (55:41) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Software Change Software change control Software change strategies Program evolution dynamics Laws of Program Evolution Applicability of Lehman's laws Software maintenance Maintenance is inevitable Causes of maintenance Distribution of maintenance effort
xvi

Software Defects Prevention Techniques Example Project

Types of Maintenance Breakup of costs Spiral maintenance model Maintenance costs Maintenance costs factors Problems facing Maintainers Approaches to Maintenance The Change process Change requests Change implementation Maintenance prediction Change prediction Complexity metrics Process metrics

26. Agile Development (55:33) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Objectives Requirements Characteristics of Agile Processes An iterative development process Advantages of incremental development Problems with incremental development Prototyping Software prototyping Benefits of prototyping Throw -away prototypes Incremental Development & Prototyping Conflicting objectives Agile methods Principles of Agile Methods Problems with agile methods Extreme programming The Four Core Values of XP Communication Feedback Courage The XP release cycle XP Practices XP Practices - 2 XP and agile principles Requirements scenarios Story Card for document downloading XP Design Guidelines XP and change Testing in XP Task cards for document downloading
xvii

Zarko Acimovic

Test Case Description Test- first development Pair programming XP Summary

27. Software Reuse (53:43) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Design with Reuse Objectives Software reuse Benefits of reuse Requirements for design with reuse Reuse problems Generator-based reuse Types of program generator Reuse through program generation Component-based development Components Component abstractions CBSE processes An opportunistic reuse process Development with reuse CBSE problems Application frameworks Framework classes Extending frameworks

28. Reuse Continued (57:07) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Application frameworks Framework classes Extending frameworks Evaluating Frameworks Framework evaluation criteria Evaluating Frameworks COTS product reuse Integration Approaches Examples of COTS muse COTS system integration problems Component development for reuse Reusable components Re-usability enhancement
xviii

Software Defects Prevention Techniques Example Project

Generalization Techniques Generating good mental Models Application families Application family specialization Inventory management systems Application family architectures A library system Library system Family member development Design patterns The Observer pattern

29. Introduction to Project Management (52:36) http://nptel.iitm.ac.in/video.php?subjectId=106101061 What is Project Management ? Who Executes a Project? An Effective PM Needs to Do the Following: Productivity Gains With Standards and Procedures Software Process is a Part of Organizational Process Software Project Phases and Activities Software Development Strategies at a Glance Project Management Process Groups: Schematic Illustration: Interaction Within and Across Project Software Development Methodology: Schematic PMBOK (2000) Framework for Project Management PMI Developed Code Of Ethics (1/2) Impact of Good Project Management Software Project Management Suggested Readings

30. Project Scope Management (1:08:45) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Scope Management Subprocesses Illustrative Comparison of Projects Another Way of Comparing Projects: PM Must Question ALL Aspects of a Project Illustration: Stakeholder Analysis

xix

Zarko Acimovic

Illustration: Objectives of a Hospital IS Illustration: Project Charter (1/3) Illustration: Project Charter (2/3) Illustration: Project Charter (3/3) Illustration: WBS Organized by phases Summary: Scope management Subprocesses

31. Project Time Management (56:51) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Project Time Management Subprocesses WBS to Precedence Relationship Precedence Diagramming Method (PDM): Types of Dependencies Illustration: PDM Network Illustration: Arrow Diagramming Method (ADM) Network Precedence Relationship to Schedule Schedule Development Preferences Illustration of a Schedule Software Support for Project Management Summary: Time Management Process

32. Estimation - I (51:42) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Estimation is an Ongoing Activity Stages in Project Estimation Estimation Approaches PERT Sizing Approach to Estimation Estimation: Levels of Application Function Point Counting Procedure Components of FP Count FP for Average Complexity Functions

33. Estimation - II (50:38) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Marketing MIS: data flow diagram General Systems Characteristics (GSCs) Value Adjustment Factor (VAF) GSC and FPC: Marketing MIS Marketing MIS: Cost and Price
xx

Software Defects Prevention Techniques Example Project

COnstructive COst MOdel (COCOMO): Intd. Marketing MIS Modules Marketing MIS: Pert sizing COCOMO Equations COCOMO Cost Drivers (1/2) COCOMO Cost Drivers (2/2) Cost Driver Effort Multipliers Effort Multipliers: Marketing MIS Marketing MIS: COCOMO Calculations Effort and Schedule Distribution by Phase (%) Marketing MIS: Phase Effort and Schedule Network Precedence: Marketing MIS Effort Distribution by Activity: Marketing MIS Critical Path marketing MIS Gantt Chart/Histogram:Marketing MIS

34. Project Quality Management (58:32) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Definitions of Quality (1/2) Definitions of Quality (2/2) Quality Management Gurus Modern Quality Management Emphasizes on: Project Quality Management Subprocess Quality Policy Strategic Planning for Quality Quality Characteristics: Illustration Boehm's Description of Quality Quality Measurements are Used for: Illustration: Template for Usability Quality Benchmarking Cost of Quality Quality Planning Process: Outputs What is Quality Assurance? Main Goals of Quality Assurance: Role of QA During Development (1/2) VV&T Activities in SW Project (1/3) VV&T Activities in SW Project (2/3) VV&T Activities in SW Project (3/3) Opportunity for Improvement (OFI) Who Identifies OFI? Improvement in Practice and Documentation Quality Control Process QC is Performed... Pareto Chart: Illustration Control Chart: Schematic

xxi

Zarko Acimovic

35. Quality Management Systems - I (54:43) http://nptel.iitm.ac.in/video.php?subjectId=106101061 36. Quality Management Systems (54:53) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Who is a Process? Process Capability and Maturity Concept of Maturity Level Capability Maturity Models (CMM) Some of the Existing CMMs Capability Maturity Model Integrated (CMMI) CMMI ls Tailorable Staged Model: Maturity Levels Maturity level Structure Structure of Staged Representation PA Level 2 PA Level 3 PA Level 4 PA Level 5 Process Visibility with levels Process Capability with Levels Continuous Representation Structure of Continuous Representation PAs in Staged Representation Capability and Maturity levels Progression in Staged model Progression in Continuous model When to chose continuous Representation? implementation Road Map

37. Project Configuration Management (53:00) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Change Control System: Schematic What is Configuration Management(CM)? CM Functions Typical Application Specific Cls Versioning of Cls Concept of Baseline Configuration Control Change Control Procedure (1/2) Change Control Procedure (2/2) Configuration Status Accounting Configuration Audit Configuration Management Plan

xxii

Software Defects Prevention Techniques Example Project

38. Project Risk Management (56:04) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Project Risk Management Processes Risk Management Planning Process Risk Manage. Planning Process: Outputs Risk identification Process Involves: Risk Analysis Processes Qualitative Risk Analysis Process Illustration: Risk Impact Rating Table Impact, Frequency, and Risk Exposure Illustration: Quantitative Risk Analysis Risk Response Planning Process (2/2) Lessening the Risks Contingency Actions Risk Monitoring and Control Process Illustration: Tracking The Top 10 Risks

39. Other PM Processes (55:41) http://nptel.iitm.ac.in/video.php?subjectId=106101061 Other Project Management Processes Project Cost Management Processes Illustration: Cost Budget (1/2) Illustration: Cost Budget (2/2) Human Resource Management Processes Impact of Organization Structure on Projects Typical Software Project Organization Software Development Responsibilities Need to be shared by all stakeholders Illustration: Responsibility Assignment Matrix Project Communications Management Processes Illustration: Stakeholder Communications Analysis Project Reporting and Review: Schematic Administrative Closure Process Covers: Administrative Closure Process Outputs Project Procurement Management Processes Project Integration Management Involves: Outputs from Project Plan Process: Uses Objectives of Overall Change Control Process Integrated Change Control Involves: Organizational Learning Role of PM Important Skills for Project Manager Engineers vs. Managers

xxiii

Zarko Acimovic

2 AUTOMATIC TOOLS FOR DEFECT PREVENTION


Prototyping (modeling) defect prevention method has efficiency 52%. Before implementing this method defect potential per 1 FP (function point) was 5, after, 2.4. Tool: ArgoUML

Static analysis of source code defect prevention method has efficiency 44%. Defect potential per 1 FP was 5, after implementing this method is 2.8. Tool: Coverity

Mathematical test case design defect prevention efficiency was 34%. Defect potential per 1 FP is 5, after is 3.3. Tool: Bullseye

Bonus: Root cause analysis 1044-1993 - IEEE Standard Classification for Software Anomalies. Efficiency 41% Before 5 After 2.95

Source: Chapter 3. Estimating and Measuring Software Quality. The Economics of Software Quality, ISBN: 9780132564762 , Capers Jones, Olivier Bonsignour http://www.amazon.com/Economics-Software-Quality-Capers-Jones/dp/0132582201 http://www.informit.com/store/product.aspx?isbn=0132582201

3 TOOLS FOR DEFECT PREVENTION IN JAVA SOFTWARE PROJECTS


Source: http://codedependents.com/2009/07/01/top-5-static-analysis-plugins-for-eclipse/

Code Coverage tool EclEmma http://www.eclemma.org/ Byte Code Analysis FindBugs http://findbugs.sourceforge.net/ Code Complexity Analysis http://www.stateofflow.com/projects/16/eclipsemetrics Dependency Analysis JDepend4Eclipse http://andrei.gmxhome.de/jdepend4eclipse/ Source Code Analysis PMD http://pmd.sourceforge.net/

xxiv

Software Defects Prevention Techniques Example Project

4 SAMPLE PROJECT SPECIFICATION


Project duration 3 months, single developer , 5000 lines of code (including comments), 15 Java 2 Micro Edition classes

Tools used: Sun J2ME Wireless Toolkit, Eclipse, IBM WebSphere Device Developer 5.5, CVS, Motorola and Nokia phone emulators and SDKs. Technology: J2ME, MIDP 2.0, CLDC 1.1. Device-independent Java 2 Micro Edition (J2ME) midlet, executable in any emulator or mobile device, for displaying map with scale, following moving objects, zoom in-out and pan, selection of location , measuring distance, following individual or vehicle on map with route presentation, presentation of waypoints on map, presentation of list of existing waypoints (sorted by name, type, distance) for selecting destination or editing and deletion, creating, editing and deletion of waypoint points with coordinates, name, type, icon; coordinates are defined by current position, selected location on map or inserted in textual form, selection of waypoint as destination and navigation towards that destination. Some classes implemented: MapBackground, MapObject, Point, SelectorPoint, PVector, MapsMIDlet Project demo web site: https://sites.google.com/site/j2memaps/

5 PMD, FINDBUGS AND STATEOFFLOW VIOLATIONS IN SOURCE CODE

Here are the violations detected in CommaHyphenString.java Description/ Line/ Type of tool

xxv

Zarko Acimovic

Description All classes and interfaces must belong to a named package Unused field: CommaHyphenString.lastIndex Use explicit scoping instead of the default package private level Document empty constructor Lines of Code in Method is 27 Number of Statements is 28 Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Use explicit scoping instead of the default package private level Local variable 'lastIndex' could be declared final Avoid variables with short names like ss
A method should have only one exit point, and that should be the last statement in the method

Line 9 12 12 13 16 16 19 19 19 20 22 24 27 27 27 27 35 44 47 47 47 53 54 54 65 65

Avoid variables with short names like v Consider replacing this Vector with the newer java.util.List Local variable 'v' could be declared final Use ArrayList instead of Vector Avoid variables with short names like ss Lines of Code in Method is 16 Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Use explicit scoping instead of the default package private level Avoid using if statements without curly braces
CommaHyphenString.getStringsOnly(String) concatenates strings using + in a loop

Prefer StringBuffer over += for concatenating strings Parameter 's' is not assigned and could be declared final Use explicit scoping instead of the default package private level

Type PMD Marker FindBugs PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker

Here is the CommaHyphenString.java source code


1 2 3 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
xxvi

/** * * CommaHyphenString parses .properties file. It eliminates commas or low

Software Defects Prevention Techniques Example Project

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

* @return String[] */ String[] getWithLowLine(String s) { int lastIndex = defineLast(s); if(lastIndex==0){ String[] ss = new String[1]; ss[0] = s; return ss; } else { int start = -1; Vector v = new Vector(); int current = s.indexOf(','); do { v.addElement(s.substring(start+1,current)); start = current; current = s.indexOf(',',current+1); } while (start!=lastIndex); String[] ss = new String[v.size()+1]; for(int i=0; i<v.size(); i++){ ss[i] = (String)v.elementAt(i); } ss[v.size()] = s.substring(lastIndex+1,s.length()); return ss; } } /** Eliminates low line * @return String[] */ String[] getStringsOnly(String s){ String[] temp = this.getWithLowLine(s); for (int i=0; i<temp.length; i++){ char[] tempChar = temp[i].toCharArray(); String k = ""; for (int j=0; j<tempChar.length; j++){ if(tempChar[j]=='_') tempChar[j]=' '; k+=tempChar[j]; } temp[i] = k; } return temp; }

/** Returns categories with low line * @return String[] */ String[] getCategoriesHyphen(String s){ return this.getWithLowLine(s); }
xxvii

Zarko Acimovic

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

/** Returns categories * @return String[] */ String[] getCategories(String s){ return this.getStringsOnly(s); } /** Defines index of last comma in string * @return integer */ public int defineLast(String s){ int lastIndex = 0; char c[] = s.toCharArray(); for (int i=0; i<c.length; i++){ if(c[i]==',') lastIndex=i; } return lastIndex; } }

CompassCanvas.java violations

xxviii

Software Defects Prevention Techniques Example Project

All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 75% Lack of Cohesion in Methods (Total Correlation) is 1,668% Number of Fields is 23 The class 'CompassCanvas' has a Cyclomatic Complexity of 6 (Highest = 17). To be compliant to J2EE, a webapp should not use any thread. Too many fields
Found non-transient, non-static member. Please mark as transient or provide accessors.

10 10 10 10 10 10 10 11 11 12 12 13 13 14 14 15 15 18 18 20 20 22 23 38 38 38 38 53 57 59 63 63 63 63 63 63 63 63 63 68

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker FindBugs FindBugs PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like c Unused field: CompassCanvas.c Avoid variables with short names like t To be compliant to J2EE, a webapp should not use any thread. Unread field: CompassCanvas.switchVar Unread field: CompassCanvas.switched It is a good practice to call super() in a constructor Lines of Code in Method is 24 Number of Statements is 33 Parameter 'mob' is not assigned and could be declared final Avoid empty catch blocks Avoid empty catch blocks To be compliant to J2EE, a webapp should not use any thread. Avoid really long methods. Avoid variables with short names like g Cyclomatic Complexity is 10 Lines of Code in Method is 220 Number of Statements is 418 Parameter 'g' is not assigned and could be declared final The method 'paint' has a Cyclomatic Complexity of 17. The method paint() has an NCSS count of 144 The method paint() has an NPath complexity of 4375 Avoid unnecessary comparisons in boolean expressions

xxix

Zarko Acimovic

CompassCanvas.java violations - continued


Avoid unused local variables such as 'mediumX'. Dead store to mediumX in CompassCanvas.paint(Graphics) The local variable mediumX is never read Avoid unused local variables such as 'mediumY'. Dead store to mediumY in CompassCanvas.paint(Graphics) The local variable mediumY is never read Avoid unnecessary comparisons in boolean expressions 122 122 122 123 123 123 285 PMD Marker FindBugs Java Problem PMD Marker FindBugs Java Problem PMD Marker

CompassCanvas.java source code


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 /** * * ComapssCanvas draws compass on screen */ import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

public class CompassCanvas extends Canvas implements Runnable{ long north; long south; long east; long west; int bigRadius; int smallRadius; int smallestRadius; Coordinates c; long delta = 0; Thread t; boolean end = false; boolean switchVar = false; boolean switched = false; MapObjects mob; int dummy1 int dummy2 int dummy3 int dummy4 Image img; = = = = 0; 0; 0; 0;

xxx

Software Defects Prevention Techniques Example Project

32 Image imgDest; 33 long destUp; 34 long destDown; 35 long gama; 36 37 38 CompassCanvas(MapObjects mob){ 39 this.mob = mob; 40 north = MathFP.toFP("0"); 41 south = MathFP.div(Coordinates.MathFP_2PI,MathFP.toFP("2")); 42 east = MathFP.mul(Coordinates.MathFP_2PI,MathFP.toFP("0.25")); 43 west = MathFP.mul(Coordinates.MathFP_2PI,MathFP.toFP("0.75")); 44 45 destUp = MathFP.toFP("0"); 46 destDown = MathFP.div(Coordinates.MathFP_2PI,MathFP.toFP("2")); 47 48 bigRadius = Math.min(this.getWidth(),this.getHeight()); 49 smallRadius = (int)(0.75*bigRadius); 50 smallestRadius = (int)(0.37*bigRadius); 51 try{ 52 img = Image.createImage("Arrow2.jpg"); 53 }catch(Exception e){} 54 55 try{ 56 imgDest = Image.createImage("Dest.jpg"); 57 }catch(Exception e){} 58 59 t = new Thread(this); 60 t.start(); 61 } 62 63 public void paint(Graphics g){ 64 //System.out.println("delta="+MathFP.toString(delta)); 65 g.setColor(255,255,255); 66 g.fillRect(0,0,this.getWidth(),this.getHeight()); 67 g.setColor(0,0,0); 68 if(end == false){ 69 g.drawImage(img,75,25,0); 70 71 //System.out.println("this.getWidth()="+this.getWidth()); 72 //System.out.println("this.getHeight()="+this.getHeight()); 73 g.drawArc(8,0,bigRadius,bigRadius,0,360); 74 g.drawArc(30,22,smallRadius,smallRadius,0,360); 75 76 String sx = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma thFP.sub(north,delta)))));

xxxi

Zarko Acimovic

77 String sy = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma thFP.sub(north,delta))))); 78 int ix = sx.indexOf('.'); 79 sx = sx.substring(0,ix); 80 int iy = sy.indexOf('.'); 81 sy = sy.substring(0,iy); 82 83 int x = Integer.parseInt(sx); 84 int y = Integer.parseInt(sy); 85 86 String s9 = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.sin(MathFP.sub(north,delta))))); 87 ix = s9.indexOf('.'); 88 s9 = s9.substring(0,ix); 89 int NX = Integer.parseInt(s9); 90 String s10 = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.cos(MathFP.sub(north,delta))))); 91 iy = s10.indexOf('.'); 92 s10 = s10.substring(0,iy); 93 int NY = Integer.parseInt(s10); 94 95 g.drawString("N",x,y,0); 96 97 sx = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma thFP.sub(south,delta))))); 98 sy = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma thFP.sub(south,delta))))); 99 ix = sx.indexOf('.'); 100 sx = sx.substring(0,ix); 101 iy = sy.indexOf('.'); 102 sy = sy.substring(0,iy); 103 104 x = Integer.parseInt(sx); 105 y = Integer.parseInt(sy); 106 107 String s11 = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.sin(MathFP.sub(south,delta))))); 108 ix = s11.indexOf('.'); 109 s11 = s11.substring(0,ix); 110 int SX = Integer.parseInt(s11); 111 String s12 = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.cos(MathFP.sub(south,delta))))); 112 iy = s12.indexOf('.'); 113 s12 = s12.substring(0,iy);
xxxii

Software Defects Prevention Techniques Example Project

114 int SY = Integer.parseInt(s12); 115 116 117 118 g.drawString("S",x,y,0); 119 int del = 0; 120 g.drawLine(NX-del,NY-del,SX-del,SY-del); 121 122 int mediumX = (int)Math.abs((NX-SX)/2); 123 int mediumY = (int)Math.abs((NY-SY)/2); 124 125 String s1 = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(10),MathFP.sin(Ma thFP.sub(east,delta))))); 126 String s2 = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(10),MathFP.cos(Ma thFP.sub(east,delta))))); 127 128 String s3 = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(10),MathFP.sin(Ma thFP.sub(west,delta))))); 129 String s4 = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(10),MathFP.cos(Ma thFP.sub(west,delta))))); 130 131 ix = s1.indexOf('.'); 132 s1 = s1.substring(0,ix); 133 dummy1 = Integer.parseInt(s1); 134 135 ix = s2.indexOf('.'); 136 s2 = s2.substring(0,ix); 137 dummy2 = Integer.parseInt(s2); 138 139 ix = s3.indexOf('.'); 140 s3 = s3.substring(0,ix); 141 dummy3 = Integer.parseInt(s3); 142 143 ix = s4.indexOf('.'); 144 s4 = s4.substring(0,ix); 145 dummy4 = Integer.parseInt(s4); 146 147 g.drawLine(NX-del,NY-del,dummy1,dummy2); 148 g.drawLine(dummy1,dummy2,SX-del,SY-del); 149 g.drawLine(NX-del,NY-del,dummy3,dummy4); 150 g.drawLine(dummy3,dummy4,SX-del,SY-del); 151 152 sx = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma thFP.sub(east,delta)))));

xxxiii

Zarko Acimovic

153 sy = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma thFP.sub(east,delta))))); 154 ix = sx.indexOf('.'); 155 sx = sx.substring(0,ix); 156 iy = sy.indexOf('.'); 157 sy = sy.substring(0,iy); 158 159 x = Integer.parseInt(sx); 160 y = Integer.parseInt(sy); 161 162 g.drawString("E",x,y,0); 163 164 sx = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(75),MathFP.sin(Ma thFP.sub(west,delta))))); 165 sy = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(75),MathFP.cos(Ma thFP.sub(west,delta))))); 166 ix = sx.indexOf('.'); 167 sx = sx.substring(0,ix); 168 iy = sy.indexOf('.'); 169 sy = sy.substring(0,iy); 170 171 x = Integer.parseInt(sx); 172 y = Integer.parseInt(sy); 173 174 g.drawString("W",x,y,0); 175 176 177 178 179 gama = MathFP.sub(delta,gama); 180 //gama = MathFP.toFP("314"); 181 long gamaDegrees = Coordinates.radiansToDegrees(gama); 182 //long gamaDegrees = gama; 183 //System.out.println("gama="+MathFP.toString(gamaDegrees)); 184 //gama = Coordinates.degreesToRadians(gama); 185 186 long corrX = MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),MathFP.sin(MathFP .sub(destUp,gama)))); 187 long corrY = MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),MathFP.cos(MathFP .sub(destUp,gama)))); 188 189 long dx = 0; 190 long dy = 0; 191
xxxiv

Software Defects Prevention Techniques Example Project

192 if(gamaDegrees<=0) { 193 gama = MathFP.add(gama,Coordinates.MathFP_2PI); 194 gamaDegrees = MathFP.add(gamaDegrees,MathFP.toFP("360")); 195 } 196 197 // Correction of position for imgDest 198 if(MathFP.toFP("0")<=gamaDegrees && gamaDegrees <MathFP.toFP("10")){ 199 dx = 0MathFP.mul(MathFP.toFP("10"),MathFP.cos(gama)); 200 dy = 0MathFP.mul(MathFP.toFP("23"),MathFP.cos(gama)); 201 } 202 203 204 if(MathFP.toFP("10")<=gamaDegrees && gamaDegrees <MathFP.toFP("50")){ 205 dx = 0MathFP.mul(MathFP.toFP("25"),MathFP.cos(gama)); 206 dy = 0MathFP.mul(MathFP.toFP("23"),MathFP.cos(gama)); 207 } 208 209 if(MathFP.toFP("50")<=gamaDegrees && gamaDegrees <MathFP.toFP("67")){ 210 dx = 0MathFP.mul(MathFP.toFP("40"),MathFP.cos(gama)); 211 dy = 0MathFP.mul(MathFP.toFP("30"),MathFP.cos(gama)); 212 } 213 214 if(MathFP.toFP("67")<=gamaDegrees && gamaDegrees <MathFP.toFP("85")){ 215 dx = 0MathFP.mul(MathFP.toFP("25"),MathFP.sin(gama)); 216 dy = 0MathFP.mul(MathFP.toFP("12"),MathFP.sin(gama)); 217 } 218 219 if(MathFP.toFP("85")<=gamaDegrees && gamaDegrees<MathFP.toFP("175")){ 220 dx = 0MathFP.mul(MathFP.toFP("25"),MathFP.sin(gama)); 221 dy = 0MathFP.mul(MathFP.toFP("12"),MathFP.sin(gama)); 222 } 223 224

xxxv

Zarko Acimovic

225 if(MathFP.toFP("175")<=gamaDegrees gamaDegrees<MathFP.toFP("275")){ 226 dx = MathFP.mul(MathFP.toFP("7"),MathFP.cos(gama)); 227 dy = MathFP.mul(MathFP.toFP("7"),MathFP.sin(gama)); 228 } 229 230 if(MathFP.toFP("275")<=gamaDegrees gamaDegrees<=MathFP.toFP("360")){ 231 dx = 0MathFP.mul(MathFP.toFP("8"),MathFP.cos(gama)); 232 dy = 0MathFP.mul(MathFP.toFP("25"),MathFP.cos(gama)); 233 234 } 235 236 237 238 239 long prevCorrX=corrX; 240 long prevCorrY=corrY; 241 242 corrX = MathFP.add(corrX,dx); 243 corrY = MathFP.add(corrY,dy); 244 245 246 247 sx = MathFP.toString(corrX); 248 sy = MathFP.toString(corrY); 249 ix = sx.indexOf('.'); 250 sx = sx.substring(0,ix); 251 iy = sy.indexOf('.'); 252 sy = sy.substring(0,iy); 253 int xbear1 = Integer.parseInt(sx); 254 int ybear1 = Integer.parseInt(sy); 255 256 257 sx = MathFP.toString(prevCorrX); 258 sy = MathFP.toString(prevCorrY); 259 ix = sx.indexOf('.'); 260 sx = sx.substring(0,ix); 261 iy = sy.indexOf('.'); 262 sy = sy.substring(0,iy); 263 int xbear3 = Integer.parseInt(sx); 264 int ybear3 = Integer.parseInt(sy); 265 266 267

&&

&&

xxxvi

Software Defects Prevention Techniques Example Project

268 sx = MathFP.toString(MathFP.add(MathFP.toFP(93),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.sin(MathFP.sub(destDown,gama))))); 269 sy = MathFP.toString(MathFP.sub(MathFP.toFP(85),MathFP.mul(MathFP.toFP(smallestRadius),M athFP.cos(MathFP.sub(destDown,gama))))); 270 271 272 ix = sx.indexOf('.'); 273 sx = sx.substring(0,ix); 274 iy = sy.indexOf('.'); 275 sy = sy.substring(0,iy); 276 int xbear2 = Integer.parseInt(sx); 277 int ybear2 = Integer.parseInt(sy); 278 279 g.drawLine(xbear2,ybear2,xbear3,ybear3); 280 g.drawImage(imgDest,xbear1,ybear1,0); 281 } 282 } 283 284 public void run(){ 285 while(end == false){ 286 delta = mob.getDirection(); 287 gama = mob.getBearing(); 288 repaint(); 289 try{ 290 Thread.sleep(100); 291 }catch(Exception e){} 292 293 } 294 } 295 296 public void setEnd(){ 297 end = true; 298 } 299 300 }

xxxvii

Zarko Acimovic

Coordinates.java violations
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 100% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 100% Lack of Cohesion in Methods (Total Correlation) is 100% Parameter 'latitude' is not assigned and could be declared final Parameter 'longitude' is not assigned and could be declared final Parameter 'original' is not assigned and could be declared final Parameter 'latitude' is not assigned and could be declared final Parameter 'longitude' is not assigned and could be declared final Avoid variables with short names like to Cyclomatic Complexity is 6 Lines of Code in Method is 47 Number of Statements is 47 Local variable 'deltaLat' could be declared final Avoid using if statements without curly braces
A method should have only one exit point, and that should be the last statement in the method

Avoid using if statements without curly braces


A method should have only one exit point, and that should be the last statement in the method

Avoid using if...else statements without curly braces


A method should have only one exit point, and that should be the last statement in the method

Avoid using if...else statements without curly braces Avoid using if statements without curly braces Avoid variables with short names like to

9 9 9 9 38 38 47 74 82 92 95 95 95 107 122 123 125 127 127 129 129 139 148

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

Coordinates.java source code

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

/** * * Coordinates class different performs geographical calculations */

//import net.jscience.math.MathFP; public class Coordinates { /** * Earth's radius (in meters) */ public static final long EARTH_RADIUS = MathFP.toFP(6367000); public static final long EARTH_RADIUS2 = MathFP.toFP(6367000*2); /** * the WGS-84 latitude of a location */
xxxviii

Software Defects Prevention Techniques Example Project

18 private long latitude; 19 /** 20 * the WGS-84 longitude of a location 21 */ 22 private long longitude; 23 /** 24 * The altitude of the location in meters, defined as height above WGS-84 ellipsoid. Float.NaN can be used to indicate that the altitude is not known. 25 */ 26 27 28 /** 29 * Constructor 30 * @param latitude latitude as WGS-84 system coordinate 31 * @param longitude longitude as WGS-84 system coordinate 32 * @param altitude the altitude in meters, if known, or Float.NaN 33 * @param timestamp the time when information stored in this object was created, in milliseconds since midnight January 1, 1970 GMT, or -1 34 * @param source the short string describing where data contained in this object came from, like "GPS", "Network", "Database", etc 35 * @param horizontalAccuracy the horizontal accuracy of coordinates in meters, or Float.NaN 36 * @param verticalAccuracy vertical accuracy of coordinates in meters, or Float.NaN 37 */ 38 public Coordinates(long latitude, long longitude){ 39 this.latitude=latitude; 40 this.longitude=longitude; 41 } 42 43 /** 44 * Copy constructor 45 * @param original copied object 46 */ 47 public Coordinates(Coordinates original){ 48 this.latitude=original.latitude; 49 this.longitude=original.longitude; 50 } 51 52 53 /** 54 * The WGS-84 latitude of a location 55 * @return WGS-84 latitude 56 */ 57 public long getLatitude(){ 58 return latitude; 59 } 60 61 /** 62 * The WGS-84 longitude of a location 63 * @return WGS-84 longitude
xxxix

Zarko Acimovic

64 */ 65 public long getLongitude(){ 66 return longitude; 67 } 68 69 70 /** 71 * Set latitude as WGS-84 system coordinate. 72 * @param latitude latitude as WGS-84 system coordinate 73 */ 74 public void setLatitude(long latitude){ 75 this.latitude=latitude; 76 } 77 78 /** 79 * Set longitude as WGS-84 system coordinate. 80 * @param longitude longitude as WGS-84 system coordinate 81 */ 82 public void setLongitude(long longitude){ 83 this.longitude=longitude; 84 } 85 86 /** 87 * Calculate bearing to another location on the surface of the Earth, using the Great Circle. 88 * bearing - 1.way of behaving 2.connection 3.direction shown by compass 4.understanding of one's position 89 * @param to another point 90 * @return long representing angle in degrees [0,360) between corresponding meridian in first point and line on the Great Circle between those points 91 */ 92 public long bearing(Coordinates to){ 93 return bearing(getLatitude(), getLongitude(), to.getLatitude(), to.getLongitude()); 94 } 95 /** 96 * Calculate bearing between points (latFrom, lonFrom) and (latTo,lonTo) on the surface of the Earth, using the Great Circle. 97 * @param latFrom latitude of the first point 98 * @param lonFrom longitude of the first point 99 * @param latTo latitude of the second point 100 * @param lonTo longitude of the second point 101 * @return long representing angle in degrees [0,360) between corresponding meridian in first point and line on the Great Circle between those points 102 */ 103 protected static long bearing(long latFrom, long lonFrom, long latTo, long lonTo){ 104 //BMa: Some numeric with MathFP still happen - but error is mostly below 16 degrees
xl

Software Defects Prevention Techniques Example Project

105 // This should be fixed only if the final target device stays without not have floats or doubles (e.g. it is not CLDC 1.1) 106 long bearing; 107 long deltaLat=latTo-latFrom; 108 long deltaLon=lonTo-lonFrom; 109 if (MathFP.abs(deltaLat)<MathFP_1 && MathFP.abs(deltaLon)<MathFP_1) { 110 // longiude and latitude distance within one deegre, could invent better condition 111 //This approximation works better for smaller distances 112 latFrom = degreesToRadians(latFrom); 113 deltaLon=MathFP.mul(deltaLon, MathFP.cos(latFrom)); 114 bearing = MathFP.atan2(deltaLat,deltaLon); 115 }else{ 116 latFrom = degreesToRadians(latFrom); 117 latTo = degreesToRadians(latTo); 118 lonFrom = degreesToRadians(lonFrom); 119 lonTo = degreesToRadians(lonTo); 120 121 122 if (latFrom==latTo && lonFrom==lonTo) 123 return 0; 124 //if (MathFP.cos(latFrom) < Double.MIN_VALUE) // Double.MIN_VALUE a small number ~ machine precision, so here we check for +/-0 125 if (MathFP.cos(latFrom) == 0 ) // Double.MIN_VALUE a small number ~ machine precision, so here we check for +/-0 126 if (latFrom > 0) 127 return MathFP.PI; // starting from N pole 128 else 129 return MathFP_2PI; // starting from S pole 130 //double bearing = radiansToDegrees(Math.atan2(Math.sin(lon2lon1)*Math.cos(lat2),Math.cos(lat1)*Math.sin(lat2)Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon2-lon1))%(2*Math.PI)); 131 132 bearing = MathFP.atan2( 133 MathFP.mul(MathFP.sin(deltaLon),MathFP.cos(latTo)), 134 MathFP.mul(MathFP.cos(latFrom),MathFP.sin(latTo))135 MathFP.mul(MathFP.mul(MathFP.sin(latFrom),MathFP.cos(latTo)),MathFP.cos(deltaLon))) ; 136 } 137 bearing = MathFP.mod(radiansToDegrees(bearing), MathFP_360); 138 139 if (bearing<0) bearing = MathFP_360 + bearing; 140 return bearing; 141 } 142 143 /** 144 * Calculate distance to another location on the surface of the Earth, using the Great Circle. 145 * @param to another point

xli

Zarko Acimovic

146 * @return distance to another location in meters, using the line on the Great Circle 147 */ 148 public long distance(Coordinates to){ 149 //BMa: Some numeric with MathFP are still possible - errors happen sometimes 150 // This should be fixed only if the final target device stays without not have floats or doubles (e.g. it is not CLDC 1.1) 151 return calculateDistance(getLatitude(), getLongitude(), to.getLatitude(), to.getLongitude()); 152 } 153 154 /** 155 * Calculate distance between points (latFrom, lonFrom) and (latTo,lonTo) on the surface of the Earth, using the Great Circle. 156 * lat , lon - degrees ([-90, +90]; [-180, +180]) 157 * 158 * @param latFrom latitude of the first point 159 * @param lonFrom longitude of the first point 160 * @param latTo latitude of the second point 161 * @param lonTo longitude of the second point 162 * @return distance to another location in meters, using the line on the Great Circle 163 */ 164 public static long calculateDistance(long latFrom, long lonFrom, long latTo, long lonTo){ 165 /* 166 * d=2*asin(sqrt((sin((latFrom-latTo)/2))^2 + cos(latFrom)*cos(latTo)*(sin((lonFrom-lonTo)/2))^2)) 167 * or 168 * d=2*asin(sqrt((sin((latFrom-latTo)/2))^2 + cos(latFrom)*cos(latTo)*(sin((lonTo-lonFrom)/2))^2)) 169 * distance = R*d 170 */ 171 172 latFrom = degreesToRadians(latFrom); 173 latTo = degreesToRadians(latTo); 174 lonFrom = degreesToRadians(lonFrom); 175 lonTo = degreesToRadians(lonTo); 176 //long distance = R * MathFP.acos(MathFP.sin(latFrom)*MathFP.sin(latTo) + MathFP.cos(latFrom)*MathFP.cos(latTo)*MathFP.cos(lonTo-lonFrom)); 177 /* 178 double distance = R * 2 * Math.asin( 179 Math.sqrt( 180 Math.pow(Math.sin((lat1-lat2)/2), 2) 181 + 182 Math.cos(lat1)*Math.cos(lat2)*Math.pow(Math.sin((lon2-lon1)/2), 2) 183 ) 184 ); 185 */
xlii

Software Defects Prevention Techniques Example Project

186 187 /* 188 System.out.print("latFrom: "+MathFP.toString(latFrom)); 189 System.out.println(" lonFrom: "+MathFP.toString(lonFrom)); 190 System.out.print("latTo: "+MathFP.toString(latTo)); 191 System.out.println(" lonTo: "+MathFP.toString(lonTo)); 192 */ 193 194 long p1=MathFP.sin(MathFP.div((latFrom-latTo), MathFP_2)); 195 p1 = MathFP.mul(p1, MathFP.toFP(1000000)); 196 //System.out.println(" p1: "+MathFP.toString(p1)); 197 p1 = MathFP.mul(p1, p1); 198 //System.out.println(" p1: "+MathFP.toString(p1)); 199 200 long p2=MathFP.sin(MathFP.div((lonTo-lonFrom), MathFP_2)); 201 p2 = MathFP.mul(p2, MathFP.toFP(1000000)); 202 //System.out.println(" p2: "+MathFP.toString(p2)); 203 p2 = MathFP.mul(p2, p2); 204 //System.out.println(" p2: "+MathFP.toString(p2)); 205 206 long sqrtarg=p1 +MathFP.mul(MathFP.mul(MathFP.cos(latFrom),MathFP.cos(latTo)),p2); 207 //System.out.println(" sqrtarg: "+MathFP.toString(sqrtarg)); 208 209 sqrtarg=MathFP.sqrt(sqrtarg); 210 //System.out.println(" sqrtarg: "+MathFP.toString(sqrtarg)); 211 212 long distance; 213 if (sqrtarg>MathFP.toFP(19000)) { //toFP("0.019")*1000000 - boundary for MathFP.asin approximation by X 214 // calculation is erroneus for small angles 215 long asinarg=MathFP.div(sqrtarg, MathFP.toFP(1000000)); 216 //System.out.println(" > asinarg: "+MathFP.toString(asinarg)); 217 asinarg=MathFP.asin(asinarg); 218 //System.out.println(" > asinarg: "+MathFP.toString(asinarg)); 219 distance = MathFP.mul(EARTH_RADIUS2, asinarg); 220 //System.out.println(" distance asin: "+MathFP.toString(distance)); 221 } else { 222 //asin(X) is aproximately equall to X, 223 //This approximation allow us to change the order of multiplication and division in order to reduce loss of significant digits 224 225 distance = MathFP.mul(EARTH_RADIUS2, sqrtarg); 226 //System.out.println(" > distance: "+MathFP.toString(distance)); 227 distance=MathFP.div(distance, MathFP.toFP(1000000)); 228 229 } 230 231 //System.out.println(" distance: "+MathFP.toString(distance)); 232 233 //if (Double.isNaN(distance)) //equivalent to (distance=0), but safer
xliii

Zarko Acimovic

234 // return 0; 235 return distance; 236 } 237 238 239 /** 240 * Convert degrees to radians 241 * @return value transformed to radians 242 * @param degrees value to be transformed to radians 243 */ 244 public static long degreesToRadians(long degrees){ 245 return MathFP.div(degrees,MathFP_180DivPI); 246 } 247 248 /** 249 * Convert radians to degrees 250 * @return value transformed to degrees 251 * @param radians value to be transformed to degrees 252 */ 253 public static long radiansToDegrees(long radians){ 254 return MathFP.mul(radians,MathFP_180DivPI); 255 } 256 257 public static final long MathFP_2 = MathFP.toFP(2); 258 public static final long MathFP_1 = MathFP.toFP(1); 259 public static final long MathFP_2PI = MathFP.mul(MathFP_2, MathFP.PI); 260 public static final long MathFP_1000 = MathFP.toFP(1000); 261 public static final long MathFP_360 = MathFP.toFP(360); 262 public static final long MathFP_180DivPI = MathFP.div(MathFP.toFP(180), MathFP.PI); 263 public static final long MathFP_0_5 = MathFP.toFP("0.5"); 264 265 266 }

xliv

Software Defects Prevention Techniques Example Project

DelRoute.java violations
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Pairwise Field Irrelation) is 67%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Parameter 'index' is not assigned and could be declared final Parameter 'routeID' is not assigned and could be declared final Use explicit scoping instead of the default package private level

5 5 6 6 7 7 8 8 12

PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

1 /** 2 * 3 * DelRoute is used when deleting route 4 */ 5 public class DelRoute { 6 int index; 7 int routeID; 8 DelRoute(int index, int routeID){ 9 this.index = index; 10 this.routeID = routeID; 11 } 12 int getIndex(){ 13 return index; 14 } 15 int getRouteID(){ 16 return routeID; 17 } 18 19 public String toString(){ 20 return "ID Route is "+routeID+"\n"+"Index of element to delet is "+index; 21 } 22 23 }

xlv

Zarko Acimovic

Friend.java violations
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 83% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 96% Lack of Cohesion in Methods (Total Correlation) is 107%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like t
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like t Parameter 'hashThread' is not assigned and could be declared final Parameter 'name' is not assigned and could be declared final Parameter 'resource' is not assigned and could be declared final Parameter 't' is not assigned and could be declared final Parameter 'hash' is not assigned and could be declared final A getX() method which returns a boolean should be named isX()

5 5 5 5 6 6 7 7 8 8 9 9 9 11 11 11 11 11 30 42

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

1 2 3 4 5 6 7 8 9 10 11 t){ 12 13 14 15 16 17 18 19 20 21 22

/** * * Friend class holds all important data for a friend */ public class Friend { String name; String resource; int hashThread; Thread4Friend t; Friend(String name, String resource, int hashThread, Thread4Friend this.name = name; this.resource = resource; this.hashThread = hashThread; this.t = t; } public String getName(){ return name; } public String getResource(){

xlvi

Software Defects Prevention Techniques Example Project

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

return resource; } public int getHash(){ return hashThread; } public void setID(int hash){ hashThread = hash; } public String toString(){ return "Friend is "+name+"\n"+"Hash is "+hashThread; } public void setFirst(){ t.setFirst(); } public boolean getThread(){ if (t==null){ return false; } else {return true; } } public void setThread(Thread4Friend t){ this.t = t; } }

xlvii

Zarko Acimovic

HeapSorter.java violations
All classes and interfaces must belong to a named package This class has too many methods, consider refactoring it. Document empty constructor Avoid variables with short names like a Avoid variables with short names like A Avoid variables with short names like as Avoid variables with short names like AS Prefer StringBuffer over += for concatenating strings Avoid variables with short names like a Parameter 'a' is not assigned and could be declared final Avoid using for statements without curly braces Parameter 'as' is not assigned and could be declared final Avoid using for statements without curly braces Lines of Code in Method is 21 Parameter 'i' is not assigned and could be declared final Local variable 'l' could be declared final Local variable 'r' could be declared final Local variable 'tmp' could be declared final Lines of Code in Method is 21 Number of Statements is 21 Parameter 'i' is not assigned and could be declared final Local variable 'l' could be declared final 5 5 7 9 10 23 24 30 37 37 38 41 42 45 45 46 47 62 67 67 67 68 PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

/** * * HeapSorter class sorts points by distance or by name */ public class HeapSorter{ HeapSorter(){} public void heapsort(long[] a){ long[]A = setHeapWithSize(a,a.length); buildHeap(A); for(int i=0; i<A.length; i++){ System.out.println(A[i]); } for(int i=a.length; i>1; i--){ a[i-1]=A[0]; A[0]=A[i-1]; A=setHeapWithSize(A,A.length-1); heapify(A,1); }
xlviii

Software Defects Prevention Techniques Example Project

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 1]=tmp; 63 64 65 66 67 68 69

a[0]=A[0]; } public void heapsort(String[] as){ String[] AS = setHeapWithSize(as,as.length); buildHeap(AS); for(int i=0; i<AS.length; i++){ System.out.println(AS[i]); } for(int i=as.length; i>1; i--){ as[i-1]=AS[0]; AS[0]=AS[i-1]; AS=setHeapWithSize(AS,AS.length-1); heapify(AS,1); } as[0]=AS[0]; } public void buildHeap(long[] a){ for(int i=a.length/2; i>0; i--) heapify(a,i); } public void buildHeap(String[] as){ for(int i=as.length/2; i>0; i--) heapify(as,i); } public void int int int heapify(long[]a, int i){ l=left(i); r=right(i); largest;

if(l<=heapSize(a) && a[l-1]>a[i-1]){ largest=l; }else{ largest=i; } if(r<=heapSize(a) && a[r-1]>a[largest-1]){ largest=r; } if(largest!=i){ //exchange a[i], a[largest] long tmp=a[i-1]; a[i-1]=a[largest-1]; a[largestheapify(a,largest); } } public void heapify(String[]as, int i){ int l=left(i); int r=right(i);
xlix

Zarko Acimovic

70 71 72 73 74 75 76 77 78 1].charAt(0)){ 79 80 81 82 83 84 as[largest-1]=tmpS; 85 86 87 } 88 89 90 public 91 92 } 93 94 public 95 96 } 97 98 public 99 100 } 101 102 public 103 104 } 105 106 public 107 108 } 109 110 public 111 112 113 114 115 116 } 117 118 public

int largest; if(l<=heapSize(as) && as[l-1].charAt(0)>as[i-1].charAt(0)){ largest=l; }else{ largest=i; } if(r<=heapSize(as) && as[r-1].charAt(0)>as[largestlargest=r; } if(largest!=i){ //exchange a[i], a[largest] String tmpS=as[i-1]; as[i-1]=as[largest-1]; heapify(as,largest); }

int heapSize(long a[]){ return a.length;

int heapSize(String as[]){ return as.length;

int parent(int i){ return(i/2);

int left(int i){ return(2*i);

int right(int i){ return(2*i+1);

long[] setHeapWithSize(long[]m , int n){ long[] k = new long[n]; for(int i=0; i<n; i++){ k[i]=m[i]; } return k;

String[] setHeapWithSize(String[]m , int n){


l

Software Defects Prevention Techniques Example Project

119 120 121 122 123 124 125

String[] k = new String[n]; for(int i=0; i<n; i++){ k[i]=m[i]; } return k; } };

ImageCanvas3.java violations
All classes and interfaces must belong to a named package Avoid variables with short names like ol
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like ol It is a good practice to call super() in a constructor Parameter 'ol' is not assigned and could be declared final Avoid variables with short names like g Parameter 'g' is not assigned and could be declared final Cyclomatic Complexity is 8 Lines of Code in Method is 38 Number of Statements is 25 Parameter 'keyCode' is not assigned and could be declared final

10 12 12 12 14 14 14 19 19 23 23 23 23

PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

/** * * ImageCanvas3 draws elements on screen and captures events on canvas */ //import java.io.IOException; import javax.microedition.lcdui.*; //import java.util.*; public class ImageCanvas3 extends Canvas { Outlook ol; ImageCanvas3(Outlook ol){ this.ol =ol; ol.setCanvasWH(this.getWidth(),this.getHeight()); } public void paint(Graphics g) { ol.drawOutlook(g); }
li

Zarko Acimovic

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

public void keyPressed (int keyCode){ //keyCode+=disabler; if(keyCode==49){ ol.ZoomIn(); repaint(); } if(keyCode==50){ ol.ZoomOut(); repaint(); } if(keyCode==51){ repaint(); }

switch (getGameAction(keyCode)) { case Canvas.UP: ol.setMap('u'); repaint(); break; case Canvas.DOWN: ol.setMap('d'); repaint(); break; case Canvas.LEFT: ol.setMap('l'); repaint(); break; case Canvas.RIGHT: ol.setMap('r'); repaint(); break; } } }

lii

Software Defects Prevention Techniques Example Project

MapBackground.java violations
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Chidamber & Kemerer) is 214 Lack of Cohesion in Methods (Henderson-Sellers) is 92% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 82% Lack of Cohesion in Methods (Total Correlation) is 1,010% Number of Fields is 47 The class 'MapBackground' has a Cyclomatic Complexity of 2 (Highest = 15). Too many fields Weighted Methods per Class is 64
Found non-transient, non-static member. Please mark as transient or provide accessors. Found non-transient, non-static member. Please mark as transient or provide accessors. Found non-transient, non-static member. Please mark as transient or provide accessors. Found non-transient, non-static member. Please mark as transient or provide accessors. Found non-transient, non-static member. Please mark as transient or provide accessors.

Avoid unused private fields such as 'upDlat'. The field MapBackground.upDlat is never read locally Unused field: MapBackground.upDlat Avoid unused private fields such as 'upMlat'. The field MapBackground.upMlat is never read locally Unused field: MapBackground.upMlat Avoid unused private fields such as 'upSlat'. The field MapBackground.upSlat is never read locally Unused field: MapBackground.upSlat Avoid unused private fields such as 'dwDlat'. The field MapBackground.dwDlat is never read locally Unused field: MapBackground.dwDlat Avoid unused private fields such as 'dwMlat'. The field MapBackground.dwMlat is never read locally Unused field: MapBackground.dwMlat The field MapBackground.dwSlat is never read locally Unused field: MapBackground.dwSlat The field MapBackground.lfDlon is never read locally Unused field: MapBackground.lfDlon The field MapBackground.lfMlon is never read locally Unused field: MapBackground.lfMlon The field MapBackground.lfSlon is never read locally Unused field: MapBackground.lfSlon The field MapBackground.rtDlon is never read locally Unused field: MapBackground.rtDlon The field MapBackground.rtMlon is never read locally

10 10 10 10 10 10 10 10 10 14 18 20 24 28 65 65 65 69 69 69 73 73 73 77 77 77 81 81 81 85 85 90 90 94 94 98 98 102 102 106

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Java Problem FindBugs PMD Marker Java Problem FindBugs PMD Marker Java Problem FindBugs PMD Marker Java Problem FindBugs PMD Marker Java Problem FindBugs Java Problem FindBugs Java Problem FindBugs Java Problem FindBugs Java Problem FindBugs Java Problem FindBugs Java Problem

liii

Zarko Acimovic

MapBacground.java violations continued


Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Unused field: MapBackground.sidePan Avoid variables with short names like x Avoid variables with short names like y Unread field: MapBackground.param Lines of Code in Method is 44 Number of Parameters is 7 Number of Statements is 47 Parameter 'name0' is not assigned and could be declared final Parameter 'name1' is not assigned and could be declared final Parameter 'name2' is not assigned and could be declared final Parameter 'latStr1' is not assigned and could be declared final Parameter 'lonStr1' is not assigned and could be declared final Avoid empty catch blocks
The String literal "3600" appears 4 times in this file; the first occurrence is on 249

Local variable 'pxy1' could be declared final Local variable 'pxy2' could be declared final Local variable 'tt1' could be declared final Local variable 'tt2' could be declared final Cyclomatic Complexity is 15 Lines of Code in Method is 50 Number of Statements is 37 The method 'setMap' has a Cyclomatic Complexity of 15. The method setMap() has an NPath complexity of 672 Avoid unnecessary comparisons in boolean expressions Avoid using if statements without curly braces Avoid using if statements without curly braces Avoid unnecessary comparisons in boolean expressions These nested if statements could be combined Avoid using if statements without curly braces Avoid unnecessary comparisons in boolean expressions These nested if statements could be combined Avoid using if statements without curly braces Avoid using if statements without curly braces Avoid unnecessary comparisons in boolean expressions These nested if statements could be combined Lines of Code in Method is 27 Number of Statements is 22

137 142 147 151 155 159 208 211 211 211 211 211 211 212 213 239 249 277 280 333 334 361 361 361 364 364 367 369 373 378 378 382 388 388 390 393 399 399 425 425

PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker FindBugs Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker

liv

Software Defects Prevention Techniques Example Project

MapBackground.java violations continued


Consider replacing this Vector with the newer java.util.List Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Avoid variables with short names like v Consider replacing this Vector with the newer java.util.List Avoid variables with short names like g Local variable 'lx' could be declared final Cyclomatic Complexity is 11 Lines of Code in Method is 67 Number of Statements is 69 478 484 484 484 484 490 491 542 542 542 PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker

1 /** 2 * 3 * MapBackground transforms map according to user actions, zoom In, zoom out or pan 4 */ 5 import java.util.*; 6 import java.io.*; 7 import javax.microedition.lcdui.*; 8 9 10 public class MapBackground { 11 12 /** Current JPEG Background of map 13 */ 14 private Image img; 15 16 /** Images for Different Zoom Levels; 17 */ 18 private Image[] zoomImg = new Image[3]; 19 20 private int zoomLevel = 0; 21 22 /** Width of current background image 23 */ 24 private long sizeX; 25 26 /** Height of current background image 27 */ 28 private long sizeY; 29 30 31 /** Float-point value of upper limit 32 */

lv

Zarko Acimovic

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

private long upLat; /** Float-point value of lower limit */ private long downLat; /** Side of upper limit */ //private char upNS; /** Side of lower limit */ //private char downNS; /** Float-point value of left limit */ private long leftLon; /** Float-point value of right limit */ private long rightLon; /** Side of left limit */ //private char leftWE; /** Side of right limit */ ///private char rightWE; /** Integer value of latitude degrees of upper limit */ private long upDlat; /** Integer value of latitude minutes of upper limit */ private long upMlat; /** Integer value of latitude seconds of upper limit */ private long upSlat; /** Integer value of latitude degrees of lower limit */ private long dwDlat; /** Integer value of latitude minutes of lower limit */ private long dwMlat; /** Integer value of latitude seconds of upper limit
lvi

Software Defects Prevention Techniques Example Project

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134

*/ private long dwSlat;

/** Integer value of longitude degrees of left limit */ private long lfDlon; /** Integer value of longitude minutes of left limit */ private long lfMlon; /** Integer value of longitude seconds of left limit */ private long lfSlon; /** Integer value of longitude degrees of right limit */ private long rtDlon; /** Integer value of longitude minutes of right limit */ private long rtMlon; /** Integer value of longitude seconds of right limit */ private long rtSlon;

/** Scale of map */ private long scale; /** Number of lat-seconds per pixel */ private long pixLat; /** Number of lon-seconds per pixel */ private long pixLon;

/** Total number of Latitude seconds for upper limit point */ long totLatSec ; /** Total number of Longitude seconds for left limit point */ long totLonSec ; /** new upper left edge due to pan or Zoom;
lvii

Zarko Acimovic

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

* newEdge represents Point of upper left corner of visible screen */ Point newEdge; /** new upper left edge due to pan or Zoom; * newEdge represents Point of upper left corner of visible screen */ Point previousEdge;

/** World coordinates of Down end of Image */ Point downEnd; /** Character that represents side of Pan */ char sidePan; /** x-coordinate of begining of image */ long x = 0; /** y-coordinate of begining of image */ long y = 0; /** Indicates beginning of pan range verticaly */ boolean reachBeginV = true; /** Indicates end of pan range verticaly */ boolean reachEndV = false; /** Indicates beginning of pan range horizontaly */ boolean reachBeginH = true; /** Indicates end of pan range horizontaly */ boolean reachEndH = false; /** Step of panning */ long step = 30; /** Counter of shifts vertically */ long movV=0; /** Counter of shifts horizontally
lviii

Software Defects Prevention Techniques Example Project

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236

*/ long movH=0; /** Name of smallest image */ String[] imgArray = new String[3]; /** Canvas Height */ private long canvasHeight; /** Canvas Width */ private long canvasWidth;

long previousPixLat; long previousPixLon; long minX; long minY; boolean param = false;

MapBackground( String name0, String name1, String name2, String latStr1, String lonStr1, String latStr2, String lonStr2 ) { if(MathFP.toFP(latStr1)>MathFP.toFP(latStr2)){ this.upLat = MathFP.toFP(latStr1); this.downLat = MathFP.toFP(latStr2); } else { this.upLat = MathFP.toFP(latStr2); this.downLat = MathFP.toFP(latStr1); } if(MathFP.toFP(lonStr1)>MathFP.toFP(lonStr2)){ this.leftLon = MathFP.toFP(lonStr2); this.rightLon = MathFP.toFP(lonStr1); } else { this.leftLon = MathFP.toFP(lonStr1); this.rightLon = MathFP.toFP(lonStr2); }

imgArray[0] = name0; imgArray[1] = name1; imgArray[2] = name2;

lix

Zarko Acimovic

237 try { 238 zoomImg[0] = Image.createImage(imgArray[0]); 239 } catch (IOException e) {} 240 241 img = zoomImg[0]; 242 sizeX = img.getWidth(); 243 sizeY = img.getHeight(); 244 245 newEdge = new Point(MathFP.toString(upLat),MathFP.toString(leftLon),"newEdge","","blanco",false); 246 247 downEnd = new Point(MathFP.toString(downLat),MathFP.toString(rightLon),"downEnd","","blanco",fals e); 248 249 this.totLatSec = MathFP.mul(this.upLat,MathFP.toFP("3600")); 250 this.totLonSec = MathFP.mul(this.leftLon,MathFP.toFP("3600")); 251 252 253 this.setPixels(); 254 } 255 256 257 258 /** Returns number of longitude seconds per pixel 259 * @return int 260 * 261 */ 262 public long getPixLon(){ 263 return pixLon; 264 } 265 266 /** Returns number of latitude seconds per pixel 267 * @return int 268 */ 269 public long getPixLat(){ 270 return pixLat; 271 } 272 273 /** Sets pixels as Float-Point when main constructor is called 274 * and when Zoom In/Out is applied 275 */ 276 public void setPixels(){ 277 long pxy1 = MathFP.mul(MathFP.sub(rightLon,leftLon),MathFP.toFP("3600")); 278 pixLon = MathFP.div(pxy1,MathFP.toFP(sizeX)); 279 280 long pxy2 = MathFP.mul(MathFP.sub(upLat,downLat),MathFP.toFP("3600"));
lx

Software Defects Prevention Techniques Example Project

281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 map ; 325 and 326 327 328 329

pixLat = MathFP.div(pxy2,MathFP.toFP(sizeY)); } /** Returns image to draw * * @return Image */ public Image getImage(){ return img; }

/** Returns total number of seconds for LEFT LONGITUDE * @return int */ public long getLonSec() { return this.totLonSec; } /** Returns total number of seconds for UPPER LATITUDE * @return int */ public long getLatSec() { return this.totLatSec; }

/** Returns Canvas height * * @return int */ public long getCanvasHeight(){ return canvasHeight; } /** Returns Canvas width * * @return int */ public long getCanvasWidth(){ return canvasWidth; } /** Sets newEdge; new Edge is created every time when user pans or zooms * newEdge represents Point of upper left corner of visible screen (x=0

* y=0 for newEdge) * * @return Point */


lxi

Zarko Acimovic

330 public void setNewEdge(){ 331 previousEdge = newEdge; 332 333 long tt1 = MathFP.mul(this.getPixLat(),MathFP.toFP(Math.abs(this.getY()))); 334 long tt2 = MathFP.mul(this.getPixLon(),MathFP.toFP(Math.abs(this.getX()))); 335 336 newEdge = new Point(MathFP.sub(this.getLatSec(),tt1), 337 MathFP.add(this.getLonSec(),tt2),"","",false); 338 } 339 340 /** Returns new edge 341 */ 342 public Point getNewEdge(){ 343 return newEdge; 344 } 345 346 /** Returns down End 347 */ 348 public Point getDownEnd(){ 349 return downEnd; 350 } 351 352 /** Returns new Edge as String 353 * 354 * @return String 355 */ 356 public String getNEdgeStr(){ 357 return newEdge.toString(); 358 } 359 360 361 /** Sets map due to Pan transformation 362 * 363 */ 364 public void setMap(char side){ 365 366 if (side=='u'){ 367 if(reachBeginV==false){ 368 y+=((this.img.getHeight() - canvasHeight)/step); 369 if(y>0) y=0; 370 movV--; 371 } 372 reachEndV=false; 373 if(movV==0) reachBeginV=true; 374 375 } 376 377 if (side=='d'){
lxii

Software Defects Prevention Techniques Example Project

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428

if(reachEndV==false){ y-=((this.img.getHeight()-canvasHeight)/step); movV++; reachBeginV=false; if(movV==step) reachEndV=true; } } if (side=='l'){ if(reachBeginH==false){ x+=((this.img.getWidth()-canvasWidth)/step); if(x>0) x=0; movH--; reachEndH=false; if(movH==0) reachBeginH=true; } } if (side=='r'){ if(reachEndH==false) { x-=((this.img.getWidth()-canvasWidth)/step); movH++; reachBeginH=false; if(movH==step) reachEndH=true; } } this.setNewEdge(); }

/** returns x-coordinate of begining of Image */ public long getX(){ return x; } /** returns y-coordinate of begining of Image */ public long getY(){ return y; } /** Zoom In */ public boolean ZoomIn(){ boolean zoom = false;
lxiii

Zarko Acimovic

429 if(zoomLevel<2){ 430 zoom = true; 431 this.setPreviousEdge(); 432 433 zoomLevel++; 434 if (zoomImg[zoomLevel]==null){ 435 try{ 436 zoomImg[zoomLevel] = Image.createImage(imgArray[zoomLevel]); 437 } catch(Exception e){} 438 } 439 this.img = zoomImg[zoomLevel]; 440 this.sizeX = this.img.getWidth(); 441 this.sizeY = this.img.getHeight(); 442 this.setPixels(); 443 444 x=0-(((this.img.getWidth()-canvasWidth)/step)*movH); 445 y=0-(((this.img.getHeight()-canvasHeight)/step)*movV); 446 447 this.setNewEdge(); 448 449 } 450 return zoom; 451 } 452 453 /** Zoom Out 454 */ 455 public boolean ZoomOut(){ 456 boolean zoom = false; 457 if(zoomLevel>0){ 458 zoom = true; 459 this.setPreviousEdge(); 460 461 zoomLevel--; 462 this.img = zoomImg[zoomLevel]; 463 this.sizeX = this.img.getWidth(); 464 this.sizeY = this.img.getHeight(); 465 this.setPixels(); 466 467 x=0-(((this.img.getWidth()-canvasWidth)/step)*movH); 468 y=0-(((this.img.getHeight()-canvasHeight)/step)*movV); 469 470 this.setNewEdge(); 471 } 472 return zoom; 473 } 474 475 476 /** Increments Pan level 477 */ 478 public void incPan(Vector v){
lxiv

Software Defects Prevention Techniques Example Project

479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529

if (step<10) step++; } /** Decrements Pan level */ public void decPan(Vector v){ if (step>3) step--; } /** Draws Layout */ public void drawMapBackground(Graphics g){ Long lx = new Long(x); Long ly = new Long(y); int xx = Integer.parseInt(lx.toString()); int yy = Integer.parseInt(ly.toString()); g.drawImage(img,xx,yy,0); } /** Set Canvas width and height */ public void setCanvasWH(int canvasWidth, int canvasHeight){ this.canvasWidth = (long)canvasWidth; this.canvasHeight = (long)canvasHeight; } public Point getPreviousEdge(){ return previousEdge; } public void setPreviousEdge(){ previousEdge = newEdge; previousPixLat = pixLat; previousPixLon = pixLon; } public long getPreviousPixLat(){ return previousPixLat; } public long getPreviousPixLon(){ return previousPixLon; } public long getZoomLevel(){ return zoomLevel; } public long imageHeight(){ return (long)img.getHeight();
lxv

Zarko Acimovic

530 } 531 532 public long imageWidth(){ 533 return (long)img.getWidth(); 534 } 535 536 public long getStep(){ 537 return step; 538 } 539 540 541 542 /** Sets Background for selected Point 543 * Used in SelectorPoint.selectWP 544 */ 545 public void setBackground(Point ww){ 546 547 long imgWidth = (long) this.img.getWidth(); 548 long imgHeight= (long) this.img.getHeight(); 549 minX = -Math.abs(imgWidth-canvasWidth); 550 minY = -Math.abs(imgHeight-canvasHeight); 551 552 long difLat = MathFP.div(Math.abs(ww.getLatSec()this.getLatSec()),pixLat); //x pixel of ww 553 long difLon = MathFP.div(Math.abs(ww.getLonSec()this.getLonSec()),pixLon); //y pixel of ww 554 long p1 = MathFP.div(difLat,MathFP.div((this.img.getHeight()canvasHeight),step)); 555 long p2 = MathFP.div(difLon,MathFP.div((this.img.getWidth()canvasWidth),step)); 556 557 p1 = MathFP.toLong(p1); 558 p2 = MathFP.toLong(p2); 559 p1--; 560 p2--; 561 562 563 564 p1*=((this.img.getHeight()-canvasHeight)/step); 565 p2*=((this.img.getWidth()-canvasWidth)/step); 566 567 /** 568 if(param==true) { 569 p1 -=((this.img.getHeight()-canvasHeight)/step); 570 p2-=((this.img.getWidth()-canvasWidth)/step); 571 572 p1 -=((this.img.getHeight()-canvasHeight)/step); 573 p2-=((this.img.getWidth()-canvasWidth)/step); 574 p2-=((this.img.getWidth()-canvasWidth)/step); 575 }*/ 576
lxvi

Software Defects Prevention Techniques Example Project

577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626

this.x = 0 - p2; // x value of screen begining this.y = 0 - p1; // y value of screen begining

movV = p1/((this.img.getHeight()-canvasHeight)/step); movH = p2/((this.img.getWidth()-canvasWidth)/step); if(x<minX){ x=minX; movH=step; } if(y<minY){ y=minY; movV=step; } if(x>0) x=0; if(y>0) y=0; if(movV<0) movV=0; if(movH<0) movH=0; if if if if (movV==step) {reachEndV=true;} else {reachEndV=false;} (movV==0) {reachBeginV=true;} else {reachBeginV=false;} (movH==step) {reachEndH=true;} else {reachEndH=false;} (movH==0) {reachBeginH=true;} else {reachBeginH=false;}

this.setNewEdge();

} /** public void stela(long p1,long p2){ p1 -=((this.img.getHeight()-canvasHeight)/step); p2+=((this.img.getWidth()-canvasWidth)/step); p1 -=((this.img.getHeight()-canvasHeight)/step); p2+=((this.img.getWidth()-canvasWidth)/step); p2+=((this.img.getWidth()-canvasWidth)/step); p2+=((this.img.getWidth()-canvasWidth)/step); }*/

lxvii

Zarko Acimovic

MapBackgroundFactory.java violations

All classes and interfaces must belong to a named package Avoid variables with short names like m
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Lines of Code in Method is 17 Number of Parameters is 7 Parameter 'name0' is not assigned and could be declared final Parameter 'name1' is not assigned and could be declared final Parameter 'name2' is not assigned and could be declared final

5 7 7 7 9 9 21 21 21

PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker

1 /** 2 * 3 * Different map formats could be implemented and dealt with with MapBackgroundFactory 4 */ 5 public class MapBackgroundFactory { 6 7 MapBackground m; 8 9 /** 10 MapBackgroundFactory(String name0, String name1, String name2, 11 int dLat1, int mLat1, int sLat1, char sdNS1, 12 int dLon1, int mLon1, int sLon1, char sdWE1, 13 int dLat2, int mLat2, int sLat2, char sdNS2, 14 int dLon2, int mLon2, int sLon2, char sdWE2, int scale){ 15 16 //m = new MapBackground(name0,name1,name2, 17 dLat1,mLat1,sLat1,sdNS1,dLon1,mLon1,sLon1,sdWE1, 18 dLat2,mLat2,sLat2,sdNS2,dLon2,mLon2,sLon2,sdWE2, scale); 19 }*/ 20 21 MapBackgroundFactory(String name0, String name1, String name2, 22 String lat1, String lon1, String lat2, String lon2){ 23 m = new MapBackground(name0,name1,name2, 24 lat1,lon1,lat2,lon2); 25 }

lxviii

Software Defects Prevention Techniques Example Project

26 27 28 29 30 31 32

public MapBackground getMapBackground(){ return m; } }

MapObjects.java violations
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Chidamber & Kemerer) is 101 Lack of Cohesion in Methods (Henderson-Sellers) is 83% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 84% Lack of Cohesion in Methods (Total Correlation) is 359% Number of Fields is 12 The class 'MapObjects' has a Cyclomatic Complexity of 3 (Highest = 17). This class has too many methods, consider refactoring it. Weighted Methods per Class is 72 Avoid variables with short names like mb
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid excessively long variable names like destinationPosition Use explicit scoping instead of the default package private level
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Vector with the newer java.util.List
Found non-transient, non-static member. Please mark as transient or provide accessors.

Unused field: MapObjects.currentRoute Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Vector with the newer java.util.List

9 9 9 9 9 9 9 9 9 11 11 11 12 13 13 14 14 15 15 16 16 16 16 17 18 18 18

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker

lxix

Zarko Acimovic

MapObjects.java violations continued

Avoid variables with short names like mb Parameter 'mb' is not assigned and could be declared final Use ArrayList instead of Vector Cyclomatic Complexity is 7 Lines of Code in Method is 41 Number of Statements is 56 Consider replacing this Vector with the newer java.util.List Local variable 'temp1' could be declared final Use ArrayList instead of Vector Consider replacing this Vector with the newer java.util.List Avoid variables with short names like wp Local variable 'wp' could be declared final Avoid variables with short names like v Local variable 'v' could be declared final Avoid unnecessary comparisons in boolean expressions Avoid variables with short names like wp Local variable 'wp' could be declared final Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Vector with the newer java.util.List Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Parameter 'wp' is not assigned and could be declared final Parameter 'wp' is not assigned and could be declared final Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Cyclomatic Complexity is 9 Lines of Code in Method is 47 Number of Levels is 5 Number of Locals in Scope is 7 Number of Statements is 73 Parameter 'g' is not assigned and could be declared final

26 26 32 36 36 36 40 40 40 41 56 56 64 64 65 69 69 81 81 81 86 86 92 117 139 139 149 149 149 149 149 151

PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker

lxx

Software Defects Prevention Techniques Example Project

MapsObjects.java violations
Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Cyclomatic Complexity is 7 Lines of Code in Method is 23 Number of Statements is 42 Avoid using if statements without curly braces Avoid unnecessary comparisons in boolean expressions Avoid using if statements without curly braces Avoid using if statements without curly braces 181 184 197 197 197 204 206 217 218 259 A method should have only one exit point, and that should be the last statement in the method Comparison of String parameter using == or != in MapObjects.removeRoute(String) 281 Cyclomatic Complexity is 9 288 Lines of Code in Method is 20 288 Number of Statements is 36 288 The method 'getDirection' has a Cyclomatic Complexity of 17. 288 The method getDirection() has an NPath complexity of 6561 288 Avoid using if statements without curly braces 296 Avoid using if statements without curly braces 297 Cyclomatic Complexity is 9 309 Lines of Code in Method is 29 309 Number of Statements is 48 309 PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker

lxxi

Zarko Acimovic

MapObjects.java

1 /** 2 * 3 * MapObjects controls appearance of all map objects on current screen 4 */ 5 import java.util.*; 6 //import java.io.*; 7 import javax.microedition.lcdui.*; 8 9 public class MapObjects { 10 11 MapBackground mb; 12 Point currentPosition; 13 Point previousPosition; 14 Point destinationPosition; 15 PVector freeWaypoints; 16 Vector routes; 17 PVector currentRoute; 18 Vector drawablePoints; 19 Hashtable friends; 20 boolean drawLine = false; 21 boolean destSet = false; 22 boolean currentSet = false; 23 24 25 26 MapObjects(MapBackground mb){ 27 this.mb = mb; 28 currentPosition = mb.getNewEdge(); 29 destinationPosition = mb.getNewEdge(); 30 currentPosition.setName("dummy"); 31 destinationPosition.setName("dummy"); 32 routes = new Vector(); 33 friends = new Hashtable(); 34 } 35 36 /** Sets drawable Points for current Screen 37 * 38 */ 39 public void setDrawablePoints(){ 40 Vector temp1 = new Vector(); 41 Vector temp2; 42 43 //check if current and destination are visible 44 if(this.currentPosition.check(mb.getNewEdge(), mb.getDownEnd())) { 45 currentPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat());

lxxii

Software Defects Prevention Techniques Example Project

46 temp1.addElement(currentPosition); 47 } 48 if(this.destinationPosition.check(mb.getNewEdge(), mb.getDownEnd())) { 49 destinationPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 50 temp1.addElement(destinationPosition); 51 } 52 53 //check which free waypoints are visible 54 temp2 = freeWaypoints.getPoints(mb.getNewEdge(),mb.getDownEnd()); 55 for (int j=0; j<temp2.size(); j++){ 56 Point wp = (Point)temp2.elementAt(j); 57 wp.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 58 temp1.addElement(wp); 59 } 60 61 62 //check which route points are visible 63 for (int i=0; i<routes.size(); i++){ 64 PVector v = (PVector)routes.elementAt(i); 65 if (v.getVisible()==true){ 66 temp2 = v.getPoints(mb.getNewEdge(),mb.getDownEnd()); 67 68 for (int j=0; j<temp2.size(); j++){ 69 Point wp = (Point)temp2.elementAt(j); 70 wp.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 71 temp1.addElement(wp); 72 } 73 } 74 } 75 drawablePoints = temp1; 76 } 77 78 /** Returns drawable Points for current Screen 79 * @return Vector 80 */ 81 public Vector getDrawablePointsOld(){ 82 83 return drawablePoints; 84 } 85 86 public Vector getDrawablePoints(){ 87 this.setDrawablePoints(); 88 return drawablePoints; 89 } 90 91 92 public void setCurrentPosition(Point wp){
lxxiii

Zarko Acimovic

93 previousPosition = currentPosition; 94 currentPosition = wp; 95 currentPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 96 currentSet = true; 97 } 98 99 /** Reset current position 100 */ 101 public void resetCurrentPosition(){ 102 currentPosition = mb.getNewEdge(); 103 drawLine = false; 104 currentSet = false; 105 } 106 107 /** Returns current position 108 * @return Point 109 */ 110 public Point getCurrentPosition(){ 111 return currentPosition; 112 } 113 114 115 /** Set destination position 116 */ 117 public void setDestinationPosition(Point wp){ 118 destinationPosition = wp; 119 destSet = true; 120 } 121 122 /** Reset destination position 123 */ 124 public void resetDestinationPosition(){ 125 destinationPosition = mb.getNewEdge(); 126 drawLine = false; 127 destSet = false; 128 } 129 130 /** Returns destination position 131 * @return Point 132 */ 133 public Point getDestinationPosition(){ 134 return destinationPosition; 135 } 136 137 /** Returns all routes 138 */ 139 public Vector getRoutes(){ 140 return routes; 141 } 142
lxxiv

Software Defects Prevention Techniques Example Project

143 /** Returns free Vector of free Points 144 */ 145 public PVector getFreeWaypoints(){ 146 return freeWaypoints; 147 } 148 149 /** Draws MapObjects --- OBSOLETED!!! 150 */ 151 public void drawMOBold(Graphics g, boolean route){ 152 long zl = mb.getZoomLevel()+1; 153 Long zzl = new Long(zl); 154 int zoomL = Integer.parseInt(zzl.toString()); 155 this.setDrawablePoints(); 156 157 // Drawing of line beetwen destination and current position 158 if(drawLine==true){ 159 currentPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 160 destinationPosition.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 161 g.drawLine(currentPosition.getXX(),currentPosition.getYY(),destinationPosition.getX X(),destinationPosition.getYY()); 162 } 163 164 // Drawing of free Points, current position and destination position 165 for(int i=0; i<drawablePoints.size(); i++){ 166 Point wp = (Point)drawablePoints.elementAt(i); 167 if(wp.getImage().equals("blanco")){ 168 g.fillRect(wp.getXX(),wp.getYY(),5*zoomL,5*zoomL); 169 g.drawString(wp.getName(),wp.getXX()+5,wp.getYY() +5,0); 170 } else { 171 Image img = null; 172 try{ 173 img = Image.createImage(wp.getImage()); 174 }catch(Exception e){} 175 g.drawImage(img,wp.getXX(),wp.getYY(),0); 176 } 177 178 } 179 180 // Drawing of route 181 if(route==true){ 182 for(int i=0; i<routes.size(); i++){ 183 PVector wpv = (PVector)routes.elementAt(i); 184 if(wpv.getVisible()==true){ 185 for(int j=0; j<wpv.size()-1; j++){

lxxv

Zarko Acimovic

186 Point wp1 = (Point) wpv.elementAt(j); 187 Point wp2 = (Point) wpv.elementAt(j+1); 188 wp1.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 189 wp2.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 190 g.drawLine(wp1.getXX(),wp1.getYY(),wp2.getXX(),wp2.getYY()); 191 } 192 } 193 } 194 } 195 } 196 197 /** Draws MapObjects 198 */ 199 public void drawMOB(Graphics g, boolean route){ 200 g.setColor(0,0,0); 201 202 freeWaypoints.drawVector(g,false,mb.getNewEdge(),mb.getPixLon(),mb.getPixLat(),mb.g etZoomLevel()); 203 204 if(friends.size()!=0) this.getFriends().drawVector(g,false,mb.getNewEdge(),mb.getPixLon(),mb.getPixLat(), 0); 205 206 if(route==true){ 207 for (int i =0; i<routes.size(); i++){ 208 PVector wpv = (PVector)routes.elementAt(i); 209 wpv.drawVector(g,route,mb.getNewEdge(),mb.getPixLon(),mb.getPixLat(),mb.getZoomLeve l()); 210 } 211 } 212 213 if(currentSet) { 214 currentPosition.drawPoint(g,mb.getNewEdge(),mb.getPixLat(),mb.getPixLon(),mb.getZoo mLevel()); 215 216 } 217 if(destSet) destinationPosition.drawPoint(g,mb.getNewEdge(),mb.getPixLat(),mb.getPixLon(),mb.ge tZoomLevel()); 218 if(currentSet && destSet) g.drawLine(currentPosition.getXX(),currentPosition.getYY(),destinationPosition.getX X(),destinationPosition.getYY()); 219 }
lxxvi

Software Defects Prevention Techniques Example Project

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270

/** Adds free Point */ public void addFreeWaypoint(Point wp){ this.freeWaypoints.addElement(wp); } /** Adds new route */ public void addRoute(PVector v){ this.routes.addElement(v); } /** Adds new Point to route with routeID on position pos */ public void addWP2Route(Point wp, int routeID, int pos) { PVector route; for (int i=0; i<routes.size(); i++){ route = (PVector)routes.elementAt(i); if(route.getID()==routeID){ route.insertElementAt(wp,pos); i=1000; } } } /** Sets free waypoints vector */ public void setFreeWaypointsV(PVector wpv){ this.freeWaypoints = wpv; } /** Measure distance */ public long measureDistance(Point wp){ if (currentPosition.equals(mb.getNewEdge())) { return -1; } else { return currentPosition.measureDistance(wp); } } public boolean currentSet(){ return currentSet; } public boolean destSet(){ return destSet;
lxxvii

Zarko Acimovic

271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320

public void removeRoute(PVector wr){ routes.removeElement(wr); } public void removeRoute(String s){ for(int i=0; i<routes.size(); i++){ PVector rt = (PVector)routes.elementAt(i); if (rt.getName()==s) { routes.removeElementAt(i); i=1000; } } } public long getDirection(){ long long long long long direction = 0; latP = previousPosition.getLat(); lonP = previousPosition.getLon(); latC = currentPosition.getLat(); lonC = currentPosition.getLon();

if(latC>latP && lonP==lonC) direction = MathFP.toFP("0"); if(latC>latP && lonC>lonP) direction = MathFP.toFP("45"); if(latP==latC && lonC>lonP) direction = MathFP.toFP("90"); if(latC<latP && lonC>lonP) direction = MathFP.toFP("135"); if(latC<latP && lonP==lonC) direction = MathFP.toFP("180"); if(latC<latP && lonC<lonP) direction = MathFP.toFP("225"); if(latP==latC && lonC<lonP) direction = MathFP.toFP("270"); if(latC>latP && lonC<lonP) direction = MathFP.toFP("315"); direction = Coordinates.degreesToRadians(direction); return direction; } /** This is not working well */ public long getBearing(){ long long long long long bearing = 0; latP = previousPosition.getLat(); lonP = previousPosition.getLon(); latD = destinationPosition.getLat(); lonD = destinationPosition.getLon();

//if(latD>latP && lonD==lonP) bearing = MathFP.toFP("0");

lxxviii

Software Defects Prevention Techniques Example Project

321 if( latD>latP && MathFP.abs(MathFP.sub(lonD,lonP))<MathFP.toFP("5") ) bearing = MathFP.toFP("0"); 322 if(latD>latP && lonD>lonP) bearing = MathFP.toFP("45"); 323 //if(latD==latP && lonD>lonP) bearing = MathFP.toFP("90"); 324 if(MathFP.abs(MathFP.sub(latD,latP))<MathFP.toFP("5") && lonD>lonP) bearing = MathFP.toFP("90"); 325 if(latD<latP && lonD>lonP) bearing = MathFP.toFP("135"); 326 //if(latD<latP && lonP==lonD) bearing = MathFP.toFP("180"); 327 if(latD<latP && MathFP.abs(MathFP.sub(lonD,lonP))<MathFP.toFP("5") ) bearing = MathFP.toFP("180"); 328 if(latD<latP && lonD<lonP) bearing = MathFP.toFP("225"); 329 //if(latP==latD && lonD<lonP) bearing = MathFP.toFP("270"); 330 if(MathFP.abs(MathFP.sub(latD,latP))<MathFP.toFP("5") && lonD<lonP) bearing = MathFP.toFP("270"); 331 if(latD>latP && lonD<lonP) bearing = MathFP.toFP("315"); 332 333 334 bearing = Coordinates.degreesToRadians(bearing); 335 return bearing; 336 337 } 338 339 340 public void addNewFriend(int friendID){ 341 Point dummy = new Point(currentPosition,false); 342 Integer frID = new Integer(friendID); 343 friends.put(frID,dummy); 344 } 345 346 public void updateFriend(Integer friendID,Point p){ 347 friends.put(friendID,p); 348 } 349 350 public void deleteFriend(int friendID){ 351 Integer frID = new Integer(friendID); 352 friends.remove(frID); 353 System.out.println(friends); 354 } 355 356 public void deleteAllFriends(){ 357 //System.out.println("YIPI YAAA YEEEEE"); 358 friends.clear(); 359 //System.out.println(friends); 360 } 361 362 363 /** Conversion of hashtable into vector 364 */ 365 public PVector getFriends(){ 366 Vector v = new Vector(); 367 Enumeration e = friends.elements();
lxxix

Zarko Acimovic

368 369 370 371 372 373 374 375 376 377 378

while(e.hasMoreElements()){ v.addElement((Point)e.nextElement()); } PVector PFriends = new PVector(v,false); return PFriends; }

lxxx

Software Defects Prevention Techniques Example Project

MapsMIDlet.java
All classes and interfaces must belong to a named package Avoid really long classes. Efferent Couplings is 36 Lack of Cohesion in Methods (Henderson-Sellers) is 90% Lack of Cohesion in Methods (Total Correlation) is 7,735% Number of Fields is 121 The class 'MapsMIDlet' has a Cyclomatic Complexity of 22 (Highest = 202). To be compliant to J2EE, a webapp should not use any thread. Too many fields Weighted Methods per Class is 150
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like mb
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like ic Avoid variables with short names like cc The field name indicates a constant but its modifiers do not The field name indicates a constant but its modifiers do not The field name indicates a constant but its modifiers do not Avoid variables with short names like d Avoid variables with short names like t1 To be compliant to J2EE, a webapp should not use any thread. To be compliant to J2EE, a webapp should not use any thread. Unused field: MapsMIDlet.t2 Unread field: MapsMIDlet.first Unread field: MapsMIDlet.gpsHash Unread field: MapsMIDlet.gpsThr Unread field: MapsMIDlet.frndThr

17 17 17 17 17 17 17 17 17 17 20 20 24 24 24 25 25 26 26 27 27 30 31 75 76 77 79 100 100 101 101 106 112 114 115

PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs FindBugs FindBugs FindBugs FindBugs

lxxxi

Zarko Acimovic

MapsMIDlet.java
Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Vector with the newer java.util.List Avoid excessively long variable names like synchronizationDone Unread field: MapsMIDlet.synchronizationDone Unused field: MapsMIDlet.setLine Unused field: MapsMIDlet.resetLine The field name indicates a constant but its modifiers do not The field name indicates a constant but its modifiers do not Unused field: MapsMIDlet.routeList Unused field: MapsMIDlet.allRoutes Unused field: MapsMIDlet.hideRoutes Unused field: MapsMIDlet.delRouteList Unused field: MapsMIDlet.delAllRoutes Unused field: MapsMIDlet.categories Lines of Code in Method is 165 Number of Statements is 121 Avoid really long methods. The method startApp() has an NCSS count of 113
The String literal "Categories" appears 8 times in this file; the first occurrence is on 332

Use ArrayList instead of Vector Avoid really long methods. Cyclomatic Complexity is 121 Lines of Code in Method is 819 Number of Levels is 6 Number of Locals in Scope is 30 Number of Statements is 716 Parameter 'c' is not assigned and could be declared final Parameter 's' is not assigned and could be declared final The method 'commandAction' has a Cyclomatic Complexity of 202. The method commandAction() has an NCSS count of 539 Avoid using if statements without curly braces Use equals() to compare object references. Use equals() to compare object references. Use equals() to compare object references. Use equals() to compare object references. Use equals() to compare object references. Avoid empty catch blocks
MapsMIDlet.commandAction(Command, Displayable) might ignore java.lang.Exception

Avoid unnecessary comparisons in boolean expressions

129 129 129 134 134 142 143 158 159 186 188 189 191 192 197 201 201 204 204 332 362 368 368 368 368 368 368 368 368 368 368 370 370 371 371 374 374 399 399 413

PMD Marker PMD Marker PMD Marker PMD Marker FindBugs FindBugs FindBugs PMD Marker PMD Marker FindBugs FindBugs FindBugs FindBugs FindBugs FindBugs Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker

lxxxii

Software Defects Prevention Techniques Example Project

MapsMIDLet.java
Avoid unnecessary comparisons in boolean expressions Avoid using if statements without curly braces Local variable 'wp' could be declared final Local variable 'wp' could be declared final Local variable 'name' could be declared final Local variable 'sel' could be declared final Local variable 'category' could be declared final The local variable category is never read Do not add empty strings Do not add empty strings Avoid empty catch blocks
MapsMIDlet.commandAction(Command, Displayable) might ignore java.lang.Exception

The local variable category is never read Do not add empty strings Do not add empty strings Avoid empty catch blocks
MapsMIDlet.commandAction(Command, Displayable) might ignore java.lang.Exception

Deeply nested if..then statements are hard to read Avoid using if statements without curly braces Avoid using if statements without curly braces Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Avoid instantiating new objects inside loops Avoid instantiating new objects inside loops Consider replacing this Vector with the newer java.util.List Avoid instantiating new objects inside loops Avoid instantiating new objects inside loops Avoid instantiating new objects inside loops Consider replacing this Vector with the newer java.util.List Consider replacing this Vector with the newer java.util.List
Write to static field MapsMIDlet.resource from instance method MapsMIDlet.commandAction(Command, Displayable)

422 422 428 434 450 451 456 456 468 468 479 479 551 563 563 574 574 599 643 644 670 695 700 735 766 775 786 828 881 881 1023 1028 1049 1105 1190 1190 1190 1190 1190 1190

PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Java Problem PMD Marker PMD Marker PMD Marker FindBugs Java Problem PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker

To be compliant to J2EE, a webapp should not use any thread. Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty() Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty() Cyclomatic Complexity is 11 Lines of Code in Method is 87 Number of Levels is 7 Number of Locals in Scope is 16 Number of Statements is 73 The method 'run' has a Cyclomatic Complexity of 17.

lxxxiii

Zarko Acimovic

MapsMIDlet.java
Parameter 'flag' is not assigned and could be declared final Lines of Code in Method is 16 Parameter 's' is not assigned and could be declared final Avoid unused local variables such as 'k'. Dead store to k in MapsMIDlet.compact(String) The local variable k is never read MapsMIDlet.compact(String) concatenates strings using + in a loop Prefer StringBuffer over += for concatenating strings Avoid unused local variables such as 'kk'. Dead store to kk in MapsMIDlet.compact(String) The local variable kk is never read Parameter 's' is not assigned and could be declared final Avoid unused local variables such as 'k'. Dead store to k in MapsMIDlet.compactFine(String) The local variable k is never read MapsMIDlet.compactFine(String) concatenates strings using + in a loop Prefer StringBuffer over += for concatenating strings Avoid unused local variables such as 'kk'. Dead store to kk in MapsMIDlet.compactFine(String) The local variable kk is never read Cyclomatic Complexity is 6 Lines of Code in Method is 31 Number of Statements is 26 Avoid empty catch blocks 1287 1291 1296 1297 1297 1297 1302 1302 1304 1304 1304 1308 1309 1309 1309 1314 1314 1316 1316 1316 1320 1320 1320 1335 PMD Marker Metrics Marker PMD Marker PMD Marker FindBugs Java Problem FindBugs PMD Marker PMD Marker FindBugs Java Problem PMD Marker PMD Marker FindBugs Java Problem FindBugs PMD Marker PMD Marker FindBugs Java Problem Metrics Marker Metrics Marker Metrics Marker PMD Marker

1 2 3 issues 4 5 6 7 8 9 10 11 12 13 14 15 16 17 { 18 19

/** * * MapsMIDlet creates control menus due to user's actions and handles GPS * */ import javax.microedition.lcdui.*; import javax.microedition.midlet.*; import java.util.*; import java.io.*;

public class MapsMIDlet extends MIDlet implements CommandListener,Runnable

lxxxiv

Software Defects Prevention Techniques Example Project

20 MapBackgroundFactory mbf = new MapBackgroundFactory("/Mali2.png", "/Srednji.png","/Veliki.png", 21 "44.83049905", "20.44570857", "44.79241639", "20.48713523"); 22 23 24 MapBackground mb; 25 MapObjects mob; 26 SelectorPoint selP; 27 Outlook oul; 28 29 PVector vwpF = new PVector("free",false); 30 ImageCanvas3 ic; 31 CompassCanvas cc; 32 33 //Point wp3 = new Point("44.81916183","20.45417165","Klub'Akademija'","j","/Cultural_or_Tourist/Event .png",true); 34 Point wp2 = new Point("44.82990854","20.45661377","25. maj","j","/Sport/Swimming.png",true); 35 Point wp1 = new Point("44.81573706","20.45998215","Sp. Knezu Mihailu","j","/Cultural_or_Tourist/Monument.png",true); 36 37 Point wp4 = new Point("44.8178034","20.45177167","Saborna crkva","j","/Cultural_or_Tourist/Church.png",true); 38 Point wp5 = new Point("44.82577520","20.45459270","Zooloski vrt","j","/Cultural_or_Tourist/Zoo.png",true); 39 40 Point wp6 = new Point("44.81293225","20.46132951","Grinet kafe","j","/Service_or_Utility/Cafe.png",true); 41 Point wp7 = new Point("44.81426084","20.45943480","Trzni centar 'Sremska'","j","/Service_or_Utility/Shop.png",true); 42 Point wp8 = new Point("44.81248939","20.46006637","Bioskop 20.oktobar","j","/Service_or_Utility/Cinema.png",true); 43 Point wp9 = new Point("44.81293225","20.46743470","Policija","j","/Service_or_Utility/Police.png",t rue); 44 Point wp10 = new Point("44.81854182","20.45711898","Filoloski fakultet","j","/Service_or_Utility/School.png",true); 45 Point wp11 = new Point("44.82518476","20.45737165","Bioskop REX","j","/Service_or_Utility/Cinema.png",true); 46 Point wp12 = new Point("44.80496078","20.47652941","Elektrotehnicki fakultet","j","/Service_or_Utility/School.png",true); 47 Point wp13 = new Point("44.80466556","20.47337150","RCUB","j","/Service_or_Utility/School.png",true) ; 48 Point wp14 = new Point("44.80865126","20.46368736","Apoteka","j","/Service_or_Utility/Pharmacy.png", true); 49 Point wp15 = new Point("44.80067980","20.45737165","Urgentni centar","j","/Service_or_Utility/Redcross.png",true);
lxxxv

Zarko Acimovic

50 51 52 53 54 /** Point wp3 = new Point(45,2 , 1,'N',22,20, 5,'E',"c1","j"); 55 Point wp4 = new Point(45,13, 2,'N',21,58, 5,'E',"d1","j"); 56 Point wp5 = new Point(46,45, 1,'N',21,20, 5,'E',"e1","j"); 57 Point wp6 = new Point(46,48,23,'N',21,23, 9,'E',"f1","j"); 58 Point wp7 = new Point(46,30,50,'N',22,25,50,'E',"g1","j"); 59 Point wp8 = new Point(46,48,59,'N',20,27,17,'E',"a","j"); 60 Point wp9 = new Point(46,45, 0,'N',20,26,15,'E',"b","j"); 61 Point wp10 = new Point(46,42, 0,'N',20,29,15,'E',"c","j"); 62 Point wp11 = new Point(46,39, 0,'N',20,29,15,'E',"d","j"); 63 Point wp12 = new Point(46,10,23,'N',20,30, 9,'E',"e","j"); 64 Point wp13 = new Point(45,50,23,'N',20,33, 9,'E',"f","j"); 65 Point wp14 = new Point(46,30,23,'N',20,52, 9,'E',"g","j"); 66 Point wp15 = new Point(46,25,23,'N',20,54, 0,'E',"h","j"); 67 Point wp16 = new Point(46,20,23,'N',20,46, 0,'E',"i","j"); 68 Point wp17 = new Point(46,10,23,'N',20,48, 0,'E',"j","j"); 69 Point wp18 = new Point(45,50,23,'N',20,35, 0,'E',"k","j"); */ 70 71 Point selectedWP; 72 73 74 ///////////////////////COMMANDS,MENUS,BUTTONS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 75 Command DUMMY; 76 Command DELIM; 77 Command MAP_CMD; 78 79 Display d = Display.getDisplay(this); 80 81 List modes; 82 Command selectCmd; 83 Command mapviewCmd; 84 Command compassCmd; 85 86 87 88 Command opt; 89 Command mod; 90 91 List MVList; 92 Command Points; 93 Command routes; 94 Command gps; 95 Command friends; 96 Command ZoomIn; 97 Command ZoomOut; 98 Command exitCmd; 99 SimpleTextForm gpsTf;
lxxxvi

Software Defects Prevention Techniques Example Project

100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

Thread t1; Thread t2; static String resource=""; boolean gpsON = false; static String show = ""; boolean first = false; List friendList; Command addNewFriend ; Command onGPSc; Command offGPSc; List gpsList; int gpsHash = 0; int gpsThr = 0; int frndThr = 0; int currentlyShowed = 0; Hashtable thrHash = new Hashtable(); Vector listOfFriends = new Vector(); SimpleTextForm friendForm; Command stopFollow; Command deleteFriends; boolean followFriends = false; List oneFriend; Command stopFollowOne; Command deleteFriend; Thread4Friend tff; Vector whiteList; String friend; boolean syncFollow = false; long globalTimeStamp = 0; boolean synchronizationDone = false; List WPselected; Command setAsCurrent; Command setDest1; Command edit; Command delete; Command measDist; Command setLine; Command resetLine;

List WPnotSel; Command setCurrent; Command setDest2; Command addWP;

lxxxvii

Zarko Acimovic

151 CommaHyphenString chs = new CommaHyphenString(); 152 TextForm tf1; // form for adding new Point on selected spot 153 TextForm tf2; // form for editing of selected Point 154 TextForm tf33; // form for adding waypoint with user entered data for (lat,lon) 155 TextForm previous; 156 TextFormImage tf11; //form for adding new Point with images for selected categories 157 TextFormImage tf22; 158 Command SAVE_CMD; 159 Command CONT_CMD; 160 Command BACK_CMD; 161 Alert a = new Alert("Warning","Please Select Point!",null,AlertType.INFO); 162 163 List WPList; //List of Points 164 Command addNewWP; 165 Command sortWP; 166 Command sortNameWP; 167 boolean showID = false; 168 Command showIDcom; 169 List previousList; 170 171 172 TextForm tfAdd; //form for adding Point with complete info about coordinates 173 174 List sorted; 175 176 177 List routeMain; 178 Command createNewRoute; 179 Command showRoutes; 180 Command delRoute; 181 182 List routeNew; 183 Command addPoint; 184 Command routeFin; 185 186 List routeList; 187 List routeOptions; 188 Command allRoutes; 189 Command hideRoutes; 190 191 List delRouteList; 192 Command delAllRoutes; 193 String nameR = ""; 194 195 PVector newRouteVector; 196 SimpleTextForm tf3; ///form for defining name of route 197 String[] categories;
lxxxviii

Software Defects Prevention Techniques Example Project

198 boolean routeSetting = false; 199 200 String[] pathToImage; 201 /** 202 * @see MIDlet#startApp() 203 */ 204 protected void startApp() throws MIDletStateChangeException { 205 206 mb = mbf.getMapBackground(); 207 mob = new MapObjects(mb); 208 209 vwpF.addElement(wp1); 210 vwpF.addElement(wp2); 211 //vwpF.addElement(wp3); 212 vwpF.addElement(wp4); 213 vwpF.addElement(wp5); 214 vwpF.addElement(wp6); 215 vwpF.addElement(wp7); 216 vwpF.addElement(wp8); 217 vwpF.addElement(wp9); 218 vwpF.addElement(wp10); 219 vwpF.addElement(wp11); 220 vwpF.addElement(wp12); 221 vwpF.addElement(wp13); 222 vwpF.addElement(wp14); 223 vwpF.addElement(wp15); 224 225 226 227 mob.setFreeWaypointsV(vwpF); 228 229 selP = new SelectorPoint(mb,mob); 230 231 oul = new Outlook(mb,mob,selP); 232 233 ic = new ImageCanvas3(oul); 234 235 236 //////////////////////////COMMANDS,MENUS,BUTTONS\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 237 238 DUMMY = new Command(" ",Command.SCREEN,1); 239 DELIM = new Command("------------------",Command.SCREEN,1); 240 MAP_CMD = new Command("View on Map",Command.BACK,1); 241 BACK_CMD = new Command("Back to Previous Screen",Command.BACK,1); 242 243 mod = new Command("Mode",Command.SCREEN,1); 244 modes = new List("",List.IMPLICIT); 245 selectCmd = new Command("Selection",Command.SCREEN,1); 246 mapviewCmd = new Command("Mapview",Command.SCREEN,1);
lxxxix

Zarko Acimovic

247 compassCmd = new Command("Compass",Command.SCREEN,1); 248 exitCmd = new Command("Exit",Command.SCREEN,1); 249 modes.append("PLEASE SELECT NEW MODE FROM MENU...",null); 250 modes.addCommand(DUMMY); 251 modes.addCommand(mapviewCmd); 252 modes.addCommand(selectCmd); 253 modes.addCommand(compassCmd); 254 modes.addCommand(exitCmd); 255 modes.setCommandListener(this); 256 257 opt = new Command("Option",Command.SCREEN,1); 258 259 260 261 // Map View options 262 MVList = new List("",List.IMPLICIT); 263 Points = new Command("Waypoints",Command.SCREEN,1); 264 routes = new Command("Routes",Command.SCREEN,1); 265 gps = new Command("GPS",Command.SCREEN,1); 266 267 friends = new Command("Friends",Command.SCREEN,1); 268 ZoomIn = new Command("Zoom In",Command.SCREEN,1); 269 ZoomOut = new Command("Zoom Out",Command.SCREEN,1); 270 //Exit = new Command("Exit",Command.EXIT,1); 271 272 MVList.addCommand(DUMMY); 273 MVList.addCommand(Points); 274 MVList.addCommand(routes); 275 MVList.addCommand(gps); 276 MVList.addCommand(friends); 277 MVList.addCommand(ZoomIn); 278 MVList.addCommand(ZoomOut); 279 MVList.addCommand(BACK_CMD); 280 MVList.setCommandListener(this); 281 282 CONT_CMD = new Command("Continue",Command.SCREEN,1); 283 gpsTf = new SimpleTextForm(false); 284 gpsTf.addCommand(CONT_CMD); 285 gpsTf.setCommandListener(this); 286 287 288 289 290 // If Point is selected 291 WPselected = new List("",List.IMPLICIT); 292 setAsCurrent = new Command("Set as Current",Command.SCREEN,1); 293 setDest1 = new Command("Set as Destination",Command.SCREEN,1); 294 edit = new Command("Edit",Command.SCREEN,1); 295 delete = new Command("Delete",Command.SCREEN,1);
xc

Software Defects Prevention Techniques Example Project

296 measDist = new Command("Measure Distance",Command.SCREEN,1); 297 298 299 WPselected.addCommand(DUMMY); 300 WPselected.addCommand(MAP_CMD); 301 WPselected.addCommand(setAsCurrent); 302 WPselected.addCommand(setDest1); 303 WPselected.addCommand(edit); 304 WPselected.addCommand(delete); 305 WPselected.addCommand(measDist); 306 WPselected.addCommand(BACK_CMD); 307 WPselected.setCommandListener(this); 308 309 310 311 // If Point is not selected 312 WPnotSel = new List("",List.IMPLICIT); 313 setCurrent = new Command("Set Current",Command.SCREEN,1); 314 setDest2 = new Command("Set Destination",Command.SCREEN,1); 315 addWP = new Command("Add Waypoint",Command.SCREEN,1); 316 317 WPnotSel.addCommand(DUMMY); 318 WPnotSel.addCommand(setCurrent); 319 WPnotSel.addCommand(setDest2); 320 WPnotSel.addCommand(addWP); 321 WPnotSel.addCommand(measDist); 322 //WPnotSel.addCommand(MAP_CMD); 323 WPnotSel.addCommand(BACK_CMD); 324 WPnotSel.setCommandListener(this); 325 326 WPList = new List("",List.IMPLICIT); 327 addNewWP = new Command("Add Waypoint",Command.SCREEN,1); 328 sortWP = new Command("Sort Waypoints by Distance",Command.SCREEN,1); 329 sortNameWP = new Command("Sort Waypoints by Name",Command.SCREEN,1); 330 showIDcom = new Command("Show/Hide ID",Command.SCREEN,1); 331 332 tfAdd = new TextForm(chs.getCategories(this.getAppProperty("Categories")),false); 333 334 tfAdd.addCommand(CONT_CMD); 335 tfAdd.setCommandListener(this); 336 337 sorted = new List("",List.IMPLICIT); 338 sorted.setCommandListener(this); 339 340 341 ic.addCommand(opt);
xci

Zarko Acimovic

342 ic.addCommand(mod); 343 ic.setCommandListener(this); 344 345 346 tf1 = new TextForm(chs.getCategories(this.getAppProperty("Categories")),false);///form for adding new Point on selected spot 347 tf2 = new TextForm(chs.getCategories(this.getAppProperty("Categories")),false);/// form for editing of selected Point 348 tf33 = new TextForm(chs.getCategories(this.getAppProperty("Categories")),true);/// form for editing of selected Point 349 350 SAVE_CMD = new Command("Save",Command.SCREEN,1); 351 352 tf1.addCommand(CONT_CMD); 353 tf1.addCommand(BACK_CMD); 354 tf1.setCommandListener(this); 355 tf2.addCommand(CONT_CMD); 356 tf2.addCommand(BACK_CMD); 357 tf2.setCommandListener(this); 358 tf33.addCommand(CONT_CMD); 359 tf33.addCommand(BACK_CMD); 360 tf33.setCommandListener(this); 361 362 whiteList = new Vector(); 363 364 d.setCurrent(ic); 365 } 366 367 368 public void commandAction(Command c, Displayable s){ 369 370 if (c==MAP_CMD) d.setCurrent(ic); 371 if (s==ic && c==mod){ 372 d.setCurrent(modes); 373 } 374 if (s==modes && c==selectCmd){ 375 oul.setSelect(); 376 ic.repaint(); 377 d.setCurrent(ic); 378 selP.resetBig(); 379 selP.resetColor(); 380 } 381 if (s==modes && c==mapviewCmd){ 382 selP.resetColor(); 383 selP.resetBig(); 384 oul.resetSelect(); 385 d.setCurrent(ic); 386 }
xcii

Software Defects Prevention Techniques Example Project

387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 d.setCurrent(WPnotSel); 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436

if (s==modes && c==compassCmd){ oul.resetSelect(); cc = new CompassCanvas(mob); cc.addCommand(MAP_CMD); cc.setCommandListener(this); d.setCurrent(cc); } if (s==modes && c==exitCmd){ try{ destroyApp(false); }catch(Exception e){} notifyDestroyed(); return; } if(s==cc && c==MAP_CMD){ cc.setEnd(); ic = new ImageCanvas3(oul); ic.addCommand(opt); ic.addCommand(mod); ic.setCommandListener(this); d.setCurrent(ic); } if (s==ic && c==opt && routeSetting==false){ if(oul.getSelect()==true) { selectedWP = selP.getSelectedWP(); if(selectedWP.getName()=="selector") if(selectedWP.getName()!="selector") { d.setCurrent(WPselected); previousList=null; } } if(oul.getSelect()==false) d.setCurrent(MVList); }

// IF Point NOT SELECTED if(s==WPnotSel && c==setCurrent){ Point wp = selP.getSelector(); wp.setName("current"); mob.setCurrentPosition(wp); d.setCurrent(ic); } if(s==WPnotSel && c==setDest2){ Point wp = selP.getSelector(); wp.setName("dest"); mob.setDestinationPosition(wp);
xciii

Zarko Acimovic

437 d.setCurrent(ic); 438 } 439 440 // ADD Point ON SELECTED SPOT 441 if(s==WPnotSel && c==addWP){ 442 tf1.setName("default"); //form for adding new Point on selected spot 443 //tf1.setType("Type will be set according to category"); 444 tf1.setLat(selP.getSelector().getLat()); 445 tf1.setLon(selP.getSelector().getLon()); 446 d.setCurrent(tf1); 447 } 448 449 if (s.equals(tf1) && c == CONT_CMD){ 450 String name = tf1.getName(); 451 int sel = tf1.getSelected(); 452 453 // chs is instance of CommaHypenString class 454 // which helps us process hyphens and commas in 455 //.properties file 456 String[] category = chs.getCategories(this.getAppProperty("Categories")); 457 String[] categoryHyphen = chs.getCategoriesHyphen(this.getAppProperty("Categories")); 458 459 // elements of a selected category: as simle strings and as hyphen-strings 460 String catMatches = this.getAppProperty(categoryHyphen[sel]); 461 String[] arCatMatches = chs.getStringsOnly(catMatches); 462 String[] arCatHyphMatches = chs.getWithLowLine(catMatches); 463 464 // images that correspond to category elements 465 String[] imageStr = new String[arCatMatches.length]; 466 Image[] img = new Image[arCatMatches.length]; 467 for(int i=0; i<arCatMatches.length; i++){ 468 imageStr[i] = this.getAppProperty(""+arCatHyphMatches[i]+""); 469 imageStr[i] = this.compact(imageStr[i]); 470 } 471 472 pathToImage = new String[arCatMatches.length]; 473 for (int i=0; i<arCatMatches.length; i++){ 474 try{ 475 String str = categoryHyphen[sel] +"/"+imageStr[i];

xciv

Software Defects Prevention Techniques Example Project

476 off blanco spots 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525

str = compact(str); //getting rid pathToImage[i] = str; img[i] = Image.createImage(str); } catch(Exception e){} } tf11 = new TextFormImage("",arCatMatches,img); tf11.setNameCHGR("Please select type"); tf11.setName(name); //tf11.setType("Please select type"); tf11.addCommand(BACK_CMD); tf11.addCommand(SAVE_CMD); tf11.setCommandListener(this); d.setCurrent(tf11); } if(s==tf1 && c==BACK_CMD){ d.setCurrent(WPnotSel); } if(s==tf11 && c==BACK_CMD){ d.setCurrent(tf1); } if(s==tf11 && c==SAVE_CMD){ Point wp = selP.getSelector(); wp.setName(tf11.getName()); int sel = tf11.getSelected(); String cmpct = compact(pathToImage[sel]); wp.setImage(cmpct); mob.addFreeWaypoint(wp); d.setCurrent(ic); } if(s==WPselected && c==setAsCurrent){ mob.setCurrentPosition(selectedWP); d.setCurrent(ic); } if(s==WPselected && c==setDest1){ mob.setDestinationPosition(selectedWP); d.setCurrent(ic); } //Edit of Point if(s==WPselected && c==edit){ tf2.setName(selectedWP.getName()); tf2.setType(selectedWP.getType()); tf2.setLat(selectedWP.getLat()); tf2.setLon(selectedWP.getLon());
xcv

Zarko Acimovic

526 d.setCurrent(tf2); 527 } 528 529 530 //Editing of waypoint OR inserting waypoint from text form 531 if ( (s.equals(tf2)||s.equals(tf33)) && c == CONT_CMD){ 532 String name =""; 533 int sel = 0; 534 535 if(s.equals(tf2)){ 536 name = tf2.getName(); 537 sel = tf2.getSelected(); 538 previous = tf2; 539 } 540 541 if(s.equals(tf33)){ 542 name = tf33.getName(); 543 sel = tf33.getSelected(); 544 previous = tf33; 545 } 546 547 548 // chs is instance of CommaHypenString class 549 // which helps us process hyphens and commas in 550 //.properties file 551 String[] category = chs.getCategories(this.getAppProperty("Categories")); 552 String[] categoryHyphen = chs.getCategoriesHyphen(this.getAppProperty("Categories")); 553 554 // elements of a selected category: as simle strings and as hyphen-strings 555 String catMatches = this.getAppProperty(categoryHyphen[sel]); 556 String[] arCatMatches = chs.getStringsOnly(catMatches); 557 String[] arCatHyphMatches = chs.getWithLowLine(catMatches); 558 559 // images that correspond to category elements 560 String[] imageStr = new String[arCatMatches.length]; 561 Image[] img = new Image[arCatMatches.length]; 562 for(int i=0; i<arCatMatches.length; i++){ 563 imageStr[i] = this.getAppProperty(""+arCatHyphMatches[i]+""); 564 imageStr[i] = this.compact(imageStr[i]); 565 } 566 567 pathToImage = new String[arCatMatches.length]; 568 for (int i=0; i<arCatMatches.length; i++){
xcvi

Software Defects Prevention Techniques Example Project

569 try{ 570 String str = categoryHyphen[sel] +"/"+imageStr[i]; 571 str = compact(str); //getting rid off blanco spots 572 pathToImage[i] = str; 573 img[i] = Image.createImage(str); 574 } catch(Exception e){} 575 } 576 577 tf22 = new TextFormImage("",arCatMatches,img); 578 tf22.setNameCHGR("Please select type"); 579 tf22.setName(name); 580 tf22.addCommand(BACK_CMD); 581 tf22.addCommand(SAVE_CMD); 582 tf22.setCommandListener(this); 583 d.setCurrent(tf22); 584 } 585 586 if(s==tf2 && c==BACK_CMD){ 587 d.setCurrent(WPselected); 588 } 589 590 if(s==tf22 && c==BACK_CMD){ 591 d.setCurrent(previous); 592 } 593 594 if(s==tf22 && c==SAVE_CMD){ 595 596 //Editing of waypoint 597 if(previous == tf2){ 598 Point wp = selP.getSelectedWP(); 599 if(wp.getLat()==0){ 600 wp = new Point(tf2.getLat(),tf2.getLon(),tf22.getName(),"","blanco",false); 601 } 602 wp.setName(tf22.getName()); 603 int sel = tf22.getSelected(); 604 String cmpct = compact(pathToImage[sel]); 605 wp.setImage(cmpct); 606 wp.setLat(tf2.getLat()); 607 wp.setLon(tf2.getLon()); 608 selP.deleteWP(); 609 mob.addFreeWaypoint(wp); 610 selP.setColor(); 611 d.setCurrent(ic); 612 } 613 614 // New waypoint from text form 615 if(previous==tf33){

xcvii

Zarko Acimovic

616 Point wp = new Point(tf33.getLat(),tf33.getLon(),tf22.getName(),"","blanco",false); 617 wp.setName(tf22.getName()); 618 int sel = tf22.getSelected(); 619 String cmpct = compact(pathToImage[sel]); 620 wp.setImage(cmpct); 621 wp.setLat(tf33.getLat()); 622 wp.setLon(tf33.getLon()); 623 mob.addFreeWaypoint(wp); 624 d.setCurrent(ic); 625 } 626 } 627 628 629 // Delete Point 630 if(s==WPselected && c==delete){ 631 int k = selP.deleteWP(); 632 if(k==-1){ 633 a.setTimeout(3000); 634 a.setString("More than one Point selected"); 635 d.setCurrent(a); 636 } else { 637 selP.resetBig(); 638 d.setCurrent(ic); 639 } 640 } 641 642 if(s==WPselected && c==BACK_CMD){ 643 if(previousList==null) d.setCurrent(ic); 644 if(previousList!=null) d.setCurrent(previousList); 645 } 646 647 648 // Measuring distance between current position and selected WAYPOINT 649 if(s==WPselected && c==measDist){ 650 if(mob.getCurrentPosition().getName().equals("dummy")){ 651 a.setTimeout(3000); 652 a.setString("Current position is not set"); 653 d.setCurrent(a); 654 655 } else { 656 a.setTimeout(3000); 657 selectedWP = selP.getSelectedWP(); 658 long k = mob.measureDistance(selectedWP); 659 a.setString("Distance is "+k+" m"); 660 d.setCurrent(a); 661 } 662
xcviii

Software Defects Prevention Techniques Example Project

663 } 664 665 666 // Measuring distance between current position and selected LOCATION 667 if(s==WPnotSel && c==measDist){ 668 selectedWP = selP.getSelector(); 669 long k = mob.measureDistance(selectedWP); 670 if(mob.currentSet()==false){ 671 a.setTimeout(3000); 672 a.setString("Current position is not set"); 673 d.setCurrent(a); 674 675 } else { 676 a.setTimeout(3000); 677 a.setString("Distance is "+k+" m"); 678 d.setCurrent(a); 679 } 680 } 681 682 if(s==WPnotSel && c==BACK_CMD) d.setCurrent(ic); 683 684 685 686 687 688 // -----------------Showing up all Points and some operations--------------689 if(s==MVList && c==Points){ 690 setWPList(); 691 692 for(int i=0; i<mob.freeWaypoints.size(); i++){ 693 Point wp = (Point)mob.freeWaypoints.elementAt(i); 694 String name = ""; 695 if(showID==true){ 696 name = wp.getName() +"_"+wp.getID(); 697 } else { 698 name = wp.getName(); 699 } 700 Command cc = new Command(name,Command.SCREEN,1); 701 WPList.addCommand(cc); 702 } 703 d.setCurrent(WPList); 704 } 705 706 if(s==MVList && c==BACK_CMD){ 707 d.setCurrent(ic); 708 }
xcix

Zarko Acimovic

709 710 if(s==MVList && c==ZoomIn){ 711 oul.ZoomIn(); 712 d.setCurrent(ic); 713 } 714 715 if(s==MVList && c==ZoomOut){ 716 oul.ZoomOut(); 717 d.setCurrent(ic); 718 } 719 720 721 // displaying of IDs of icons 722 if(s==WPList && c==showIDcom){ 723 if(showID==true) {showID=false; } else {showID=true;} 724 725 setWPList(); 726 727 for(int i=0; i<mob.freeWaypoints.size(); i++){ 728 Point wp = (Point)mob.freeWaypoints.elementAt(i); 729 String name = ""; 730 if(showID==true){ 731 name = wp.getName() +"_"+wp.getID(); 732 } else { 733 name = wp.getName(); 734 } 735 Command cc = new Command(name,Command.SCREEN,1); 736 WPList.addCommand(cc); 737 } 738 d.setCurrent(WPList); 739 } 740 741 742 // Adding new Point with all attributes such as 743 // LATITUDE and LONGITUDE 744 // We deal with tf33 same as with tf2 (tf2 is used for 745 // inserting new data for selected location 746 // Here default values for coordinates are those of center of the map 747 748 if(s==WPList && c==addNewWP){ 749 tf33.setName("Center of Map");//44.80345511,20.42949821 750 tf33.setType(""); 751 tf33.setLat("44.80345511"); 752 tf33.setLon("20.42949821"); 753 d.setCurrent(tf33);
c

Software Defects Prevention Techniques Example Project

754 } 755 756 757 758 if(s==tf33 && c==BACK_CMD){ 759 d.setCurrent(WPList); 760 } 761 762 //sorting waypoints by distance 763 if(s==WPList && c==sortWP){ 764 setWPList(); 765 766 Vector sor = mob.freeWaypoints.sortAscending(mob.getCurrentPosition()); 767 for(int i=0; i<sor.size(); i++){ 768 Point wp = (Point)sor.elementAt(i); 769 String name = ""; 770 if(showID==true){ 771 name = wp.getName()+" "+wp.getID(); 772 } else { 773 name = wp.getName(); 774 } 775 Command cc = new Command(name,Command.SCREEN,1); 776 WPList.addCommand(cc); 777 } 778 d.setCurrent(WPList); 779 } 780 781 //sorting waypoints by name 782 if(s==WPList && c==sortNameWP){ 783 setWPList(); 784 String[] sor = mob.freeWaypoints.sortByName(); 785 for(int i=0; i<sor.length; i++){ 786 Command cc = new Command(sor[i],Command.SCREEN,1); 787 WPList.addCommand(cc); 788 } 789 d.setCurrent(WPList); 790 } 791 792 793 if(s==WPList && c==MAP_CMD){ 794 d.setCurrent(ic); 795 } 796 797 if(s==WPList && c==BACK_CMD){ 798 d.setCurrent(MVList); 799 } 800 801 //Displaying selected waypoint
ci

Zarko Acimovic

802 if(s==WPList && c!=sortWP && c!=addNewWP && c!=MAP_CMD && c!=sortNameWP && c!=DUMMY && c!=BACK_CMD){ 803 String name = c.getLabel(); 804 mb.param=true; 805 selP.selectWP(name); 806 oul.setSelect(); 807 oul.setWPselection(); 808 d.setCurrent(WPselected); 809 previousList = WPList; 810 } 811 812 813 814 // -------------- ROUTES -------------------------------815 816 // Main Menu for Routes 817 if(s==MVList && c==routes){ 818 routeMain = new List("",List.IMPLICIT); 819 createNewRoute = new Command("New Route",Command.SCREEN,1); 820 routeMain.addCommand(DUMMY); 821 routeMain.addCommand(createNewRoute); 822 routeMain.addCommand(BACK_CMD); 823 routeMain.addCommand(DELIM); 824 routeMain.setCommandListener(this); 825 for(int i=0; i<mob.getRoutes().size(); i++){ 826 PVector route = (PVector)mob.getRoutes().elementAt(i); 827 String name = route.getName(); 828 Command cr = new Command(name,Command.SCREEN,1); 829 routeMain.addCommand(cr); 830 } 831 d.setCurrent(routeMain); 832 } 833 834 if(s==routeMain && c==BACK_CMD){ 835 d.setCurrent(MVList); 836 } 837 838 //Creating a New Route 839 if(s==routeMain && c==createNewRoute){ 840 tf3 = new SimpleTextForm(false); 841 tf3.addCommand(SAVE_CMD); 842 tf3.setCommandListener(this); 843 d.setCurrent(tf3); 844 } 845 846 847 if(s==tf3 && c==SAVE_CMD){ 848 newRouteVector = new PVector("",true);
cii

Software Defects Prevention Techniques Example Project

849 newRouteVector.setName(tf3.getName()); 850 newRouteVector.setVisible(); 851 mob.addRoute(newRouteVector); 852 853 routeNew = new List("",List.IMPLICIT); 854 addPoint = new Command("Add Waypoint",Command.SCREEN,1); 855 routeFin = new Command("Route Finished",Command.SCREEN,1); 856 routeNew.addCommand(addPoint); 857 routeNew.addCommand(routeFin); 858 routeNew.setCommandListener(this); 859 860 d.setCurrent(routeNew); 861 } 862 863 864 // Selection of specific route 865 if(s==routeMain && c!=createNewRoute && c!=DUMMY && c! =BACK_CMD && c!=DELIM){ 866 nameR = c.getLabel(); 867 routeOptions = new List("",List.IMPLICIT); 868 showRoutes = new Command("Show/Hide Route",Command.SCREEN,1); 869 delRoute = new Command("Delete Route",Command.SCREEN,1); 870 routeOptions.addCommand(DUMMY); 871 routeOptions.addCommand(MAP_CMD); 872 routeOptions.addCommand(showRoutes); 873 routeOptions.addCommand(delRoute); 874 routeOptions.addCommand(BACK_CMD); 875 routeOptions.setCommandListener(this); 876 d.setCurrent(routeOptions); 877 } 878 879 //Viewing selected route 880 if(s==routeOptions && c==showRoutes){ 881 Vector allR = (Vector) mob.getRoutes(); 882 for(int i=0; i<allR.size(); i++){ 883 PVector rt = (PVector)allR.elementAt(i); 884 if(rt.getName()==nameR) { 885 if(rt.size()!=0){ 886 if(rt.getVisible()==true){ 887 rt.resetVisible(); 888 d.setCurrent(ic); 889 }else{ 890 rt.setVisible(); 891 Point wp = (Point) rt.elementAt(0); 892 String name = wp.getName();
ciii

Zarko Acimovic

893 selP.selectWP(name); 894 895 896 897 898 899 900 901 902 points to show"); 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941

oul.setSelect(); selP.resetColor(); selP.resetBig(); d.setCurrent(ic); } } if(rt.size()==0){ a.setTitle("Warning"); a.setString("Route has no a.setTimeout(5000); d.setCurrent(a); } } if(rt.getName()!=nameR) rt.resetVisible(); } }

//Deletion of selected route if(s==routeOptions && c==delRoute){ Vector v = mob.getRoutes(); for(int i=0; i<v.size(); i++){ PVector wpv = (PVector)v.elementAt(i); if(wpv.getName()==nameR){ mob.removeRoute(nameR); i=1000; } } d.setCurrent(ic); }

//Mapview if(s==routeOptions && c==MAP_CMD){ Vector v = mob.getRoutes(); for(int i=0; i<v.size(); i++){ PVector wpv = (PVector)v.elementAt(i); if(wpv.getName()==nameR){ Point p = (Point) wpv.elementAt(0); selP.selectWP(p.getName()); oul.setSelect(); oul.setWPselection(); i=1000; } } d.setCurrent(ic); }
civ

Software Defects Prevention Techniques Example Project

942 943 //Back on routeMain 944 if(s==routeOptions && c==BACK_CMD){ 945 d.setCurrent(routeMain); 946 } 947 948 949 950 951 952 //Adding new point in current route 953 if(s==routeNew && c==addPoint){ 954 if(oul.getSelect()==true){ 955 mob.removeRoute(newRouteVector); 956 Point wp = selP.getSelector(); 957 wp.setTypeID(newRouteVector.getID()); 958 wp.setName(newRouteVector.getName()); 959 wp.setImage("route"); 960 newRouteVector.addElement(wp); 961 mob.addRoute(newRouteVector); 962 d.setCurrent(ic); 963 } 964 965 if(oul.getSelect()==false){ 966 oul.setSelect(); 967 oul.setRoute(); 968 routeSetting = true; 969 d.setCurrent(ic); 970 } 971 972 } 973 974 if(s==ic && routeSetting==true && c==opt){ 975 d.setCurrent(routeNew); 976 } 977 978 if(s==routeNew && c==routeFin){ 979 oul.resetSelect(); 980 routeSetting = false; 981 d.setCurrent(ic); 982 } 983 984 985 986 987 988 989 //--------------------------------GPS ON/OFF-----------------------------990 991 if(s==MVList && c==gps){
cv

Zarko Acimovic

992 gpsList = new List("",List.IMPLICIT); 993 onGPSc = new Command("On",Command.SCREEN,1); 994 offGPSc = new Command("Off",Command.SCREEN,1); 995 gpsList.addCommand(onGPSc); 996 gpsList.addCommand(offGPSc); 997 gpsList.setCommandListener(this); 998 d.setCurrent(gpsList); 999 } 1000 1001 if(s==gpsList && c==onGPSc){ 1002 if(gpsON==false){ 1003 gpsON=true; 1004 followFriends = false; 1005 //Specifying GPS coordinates resource 1006 gpsTf.setLabel("Please select source of GPS coordinates, usually it's GPS.txt"); 1007 gpsTf.setName("GPS.txt"); 1008 gpsTf.setType("GPS.txt"); 1009 d.setCurrent(gpsTf); //GPS textform 1010 } else { 1011 d.setCurrent(ic); 1012 } 1013 } 1014 1015 if(s==gpsList && c==offGPSc){ 1016 gpsON=false; 1017 d.setCurrent(ic); 1018 } 1019 1020 1021 1022 if(s==gpsTf && c==CONT_CMD){ 1023 resource = gpsTf.getName(); 1024 1025 syncFollow = true; 1026 synchronizationDone=false; 1027 1028 t1=new Thread(this); 1029 currentlyShowed = t1.hashCode(); 1030 gpsHash = t1.hashCode(); 1031 t1.start(); 1032 d.setCurrent(ic); 1033 1034 } 1035 1036 // --------------------------- HANDLING FRIENDS' ISSUES ------------------1037 1038 if(s==MVList && c==friends){ 1039 friendList = new List("",List.IMPLICIT);

cvi

Software Defects Prevention Techniques Example Project

1040 addNewFriend = new Command("Add New Friend", Command.SCREEN,1); 1041 stopFollow = new Command("Stop Follow Friends", Command.SCREEN,1); 1042 deleteFriends = new Command("Delete Friends", Command.SCREEN,1); 1043 friendList.addCommand(DUMMY); 1044 friendList.addCommand(addNewFriend); 1045 friendList.addCommand(stopFollow); 1046 friendList.addCommand(deleteFriends); 1047 friendList.addCommand(BACK_CMD); 1048 friendList.addCommand(DELIM); 1049 if(listOfFriends.size()>0){ 1050 for (int i=0; i<listOfFriends.size(); i++){ 1051 Friend f = (Friend)listOfFriends.elementAt(i); 1052 Command cc = new Command(f.getName(),Command.SCREEN,1); 1053 friendList.addCommand(cc); 1054 } 1055 } 1056 friendList.setCommandListener(this); 1057 d.setCurrent(friendList); 1058 } 1059 1060 if(s==friendList && c==addNewFriend){ 1061 friendForm = new SimpleTextForm(false); 1062 friendForm.setLabel("Friend"); 1063 friendForm.setLabel2("Source of coordinates"); 1064 friendForm.setName("Mika"); 1065 friendForm.setType("Mika.txt"); 1066 1067 friendForm.addCommand(CONT_CMD); 1068 friendForm.setCommandListener(this); 1069 1070 d.setCurrent(friendForm); 1071 } 1072 1073 if(s==friendForm && c==CONT_CMD){ 1074 tff = new Thread4Friend(whiteList,friendForm.getName(),mob,ic,mb,oul); 1075 Integer hID = new Integer(tff.getID()); 1076 whiteList.addElement(hID); 1077 1078 tff.start(); 1079 Friend f = new Friend(friendForm.getName(),friendForm.getType(),tff.getID(),tff); 1080 listOfFriends.addElement(f); 1081 d.setCurrent(ic); 1082 } 1083
cvii

Zarko Acimovic

1084 if(s==friendList && c==stopFollow){ 1085 whiteList.removeAllElements(); 1086 mob.deleteAllFriends(); 1087 ic.repaint(); 1088 d.setCurrent(ic); 1089 } 1090 1091 if(s==friendList && c==deleteFriends){ 1092 mob.deleteAllFriends(); 1093 listOfFriends.removeAllElements(); 1094 friendList = new List("",List.IMPLICIT); 1095 addNewFriend = new Command("Add New Friend", Command.SCREEN,1); 1096 stopFollow = new Command("Stop Follow Friends", Command.SCREEN,1); 1097 deleteFriends = new Command("Delete Friends", Command.SCREEN,1); 1098 friendList.addCommand(DUMMY); 1099 friendList.addCommand(addNewFriend); 1100 friendList.addCommand(stopFollow); 1101 friendList.addCommand(deleteFriends); 1102 //friendList.addCommand(MAP_CMD); 1103 friendList.addCommand(BACK_CMD); 1104 friendList.addCommand(DELIM); 1105 if(listOfFriends.size()>0){ 1106 for (int i=0; i<listOfFriends.size(); i++){ 1107 Friend f = (Friend)listOfFriends.elementAt(i); 1108 Command cc = new Command(f.getName(),Command.SCREEN,1); 1109 friendList.addCommand(cc); 1110 } 1111 } 1112 friendList.setCommandListener(this); 1113 d.setCurrent(friendList); 1114 d.setCurrent(friendList); 1115 } 1116 1117 if(s==friendList && c!=addNewFriend && c!=stopFollow && c! =deleteFriends && c!=MAP_CMD && c!=BACK_CMD && c!=DELIM){ 1118 friend = c.getLabel(); 1119 friend = compact(friend); 1120 oneFriend = new List("",List.IMPLICIT); 1121 stopFollowOne = new Command("Stop Follow", Command.SCREEN,1); 1122 deleteFriend = new Command("Delete", Command.SCREEN,1); 1123 oneFriend.addCommand(DUMMY); 1124 oneFriend.addCommand(MAP_CMD); 1125 oneFriend.addCommand(stopFollowOne); 1126 oneFriend.addCommand(deleteFriend);
cviii

Software Defects Prevention Techniques Example Project

1127 oneFriend.addCommand(BACK_CMD); 1128 oneFriend.setCommandListener(this); 1129 1130 d.setCurrent(oneFriend); 1131 } 1132 1133 if(s==friendList && c==BACK_CMD){ 1134 d.setCurrent(MVList); 1135 } 1136 1137 if(s==oneFriend && c==MAP_CMD){ 1138 for(int i=0; i<listOfFriends.size(); i++){ 1139 Friend f = (Friend)listOfFriends.elementAt(i); 1140 if(f.getName().equals(friend)) { 1141 1142 if(f.getThread()==false){ 1143 tff = new Thread4Friend(whiteList,f.getName(),mob,ic,mb,oul); 1144 Integer hID = new Integer(tff.getID()); 1145 whiteList.addElement(hID); 1146 f.setID(tff.getID()); 1147 f.setThread(tff); 1148 tff.setFirst(); 1149 tff.start(); 1150 } else { 1151 f.setFirst(); 1152 } 1153 } 1154 } 1155 d.setCurrent(ic); 1156 } 1157 1158 if(s==oneFriend && c==BACK_CMD){ 1159 d.setCurrent(friendList); 1160 } 1161 1162 if(s==oneFriend && c==stopFollowOne){ 1163 for(int i=0; i<listOfFriends.size(); i++){ 1164 Friend f = (Friend)listOfFriends.elementAt(i); 1165 if(f.getName().equals(friend)) { 1166 whiteList.removeElement(new Integer(f.getHash())); 1167 mob.deleteFriend(f.getHash()); 1168 f.setThread(null); 1169 } 1170 } 1171 d.setCurrent(ic); 1172 }
cix

Zarko Acimovic

1173 1174 if(s==oneFriend && c==deleteFriend){ 1175 for(int i=0; i<listOfFriends.size(); i++){ 1176 Friend f = (Friend)listOfFriends.elementAt(i); 1177 if(f.getName().equals(friend)) { 1178 whiteList.removeElement(new Integer(f.getHash())); 1179 mob.deleteFriend(f.getHash()); 1180 listOfFriends.removeElementAt(i); 1181 } 1182 } 1183 d.setCurrent(ic); 1184 } 1185 1186 } 1187 1188 1189 //----------------------This part of code deals with GPS--------------------1190 public void run(){ 1191 while(followFriends==true || gpsON==true){ 1192 String s = this.getResourceAsString(resource); 1193 int nextIndex = 6; 1194 int index = s.indexOf('\n'); 1195 1196 nextIndex = s.indexOf('\n',index+1); 1197 1198 int lastIndex = s.lastIndexOf('\n'); 1199 1200 int begin = -2; 1201 int end = index; 1202 1203 String c1 = ""; 1204 String c2 = ""; 1205 String timeStamp = ""; 1206 long currentTS = 0; 1207 1208 while(index<lastIndex && gpsON==true){ 1209 Thread t = Thread.currentThread(); 1210 if(t.hashCode()==currentlyShowed){ 1211 /** 1212 if(synchronizationDone==false && syncFollow==true){ 1213 do{ //Synchronization 1214 String temp = s.substring(begin+2,end); 1215 temp = compact(temp); 1216 int comma = temp.indexOf(',');
cx

Software Defects Prevention Techniques Example Project

1217 temp.substring(0,comma); 1218 temp.indexOf(',',comma+1); 1219 temp.substring(comma+1,nextComma); 1220 temp.substring(nextComma+1,temp.length()); 1221 Long.parseLong(timeStamp); 1222 1223 1224 1225 s.indexOf('\n',nextIndex+1); 1226 while(currentTS<this.getTimeStamp()); 1227 1228 1229 1230 1231 1232 Point(c2,c1,resource,"","blanco",true); 1233 1234 1235 this.setTimeStamp(currentTS); 1236 1237 1238 s.substring(begin+2,end); 1239 1240 temp da bude prazno 1241 1242 1243 1244 temp.indexOf(','); 1245 temp.substring(0,comma); 1246 temp.indexOf(',',comma+1); 1247 temp.substring(comma+1,nextComma); 1248 temp.substring(nextComma+1,temp.length()); 1249 Long.parseLong(timeStamp); 1250
cxi

c1 = int nextComma = c2 = timeStamp = currentTS = begin = index-1; end = nextIndex; index = nextIndex; nextIndex = } synchronizationDone = true; }*/ Point wp = null; if(!c1.equals("")){ wp = new } if(syncFollow==true)

} String temp = temp = compact(temp); if(temp.equals("")){ //na kraju ce index = lastIndex+1; } else { temp = compact(temp); int comma = c1 = int nextComma = c2 = timeStamp = currentTS =

Zarko Acimovic

1251 begin = index-1; 1252 end = nextIndex; 1253 index = nextIndex; 1254 nextIndex = s.indexOf('\n',nextIndex+1); 1255 } 1256 1257 try{ 1258 Thread.sleep(1000); 1259 }catch(Exception e){} 1260 1261 if(wp!=null){ 1262 mob.setDrawablePoints(); 1263 if(gpsON==true){ 1264 mob.setCurrentPosition(wp); 1265 if((mob.getCurrentPosition().getX()>170 || mob.getCurrentPosition().getY()>160 || 1266 mob.getCurrentPosition().getX()<10 || mob.getCurrentPosition().getY()<10) && oul.getSelect()==false ) 1267 mb.setBackground(wp); 1268 ic.repaint(); 1269 1270 } 1271 } 1272 } 1273 } 1274 } 1275 1276 } 1277 1278 /** 1279 * @see MIDlet#pauseApp() 1280 */ 1281 protected void pauseApp() { 1282 } 1283 1284 /** 1285 * @see MIDlet#destroyApp(boolean) 1286 */ 1287 protected void destroyApp(boolean flag) throws MIDletStateChangeException { 1288 } 1289 1290 1291 /** Blanco characters are possible to occur in names of pictures; 1292 * Integer representations of blanko characters are 9 and 32 1293 * Also, characters with integer representation between 0 and 33
cxii

Software Defects Prevention Techniques Example Project

1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344

* can not be printed out in WSDD console, so I excluded them too */ public String compact(String s){ int k = s.length(); char[] d = s.toCharArray(); String ret = ""; for(int i=0; i<d.length; i++){ int temp = (int)d[i]; if(temp>32) ret+=d[i]; } int kk = ret.length(); return ret; } public String compactFine(String s){ int k = s.length(); char[] d = s.toCharArray(); String ret = ""; for(int i=0; i<d.length; i++){ int temp = (int)d[i]; if(temp!=32 && temp!=9) ret+=d[i]; } int kk = ret.length(); return ret; } public String getResourceAsString(String resource){ InputStream is = null; try{ is = this.getClass().getResourceAsStream(resource); }catch(Exception e) { a.setString("There is no such resource"); d.setCurrent(a); } //conversion of resource into string String s = ""; char m =' '; try{ m = (char)is.read(); }catch(Exception e){} while(m!=65535){ s+=m; try{ m = (char)is.read(); }catch(Exception e){} } try{ is.close();
cxiii

Zarko Acimovic

1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375

}catch(Exception e){}

s=compactFine(s); return s; } public long getTimeStamp(){ return globalTimeStamp; } public void setTimeStamp(long tms){ globalTimeStamp = tms; } public void setWPList(){ WPList = new List("",List.IMPLICIT); WPList.addCommand(DUMMY); WPList.addCommand(addNewWP); WPList.addCommand(sortWP); WPList.addCommand(sortNameWP); WPList.addCommand(showIDcom); WPList.addCommand(BACK_CMD); WPList.addCommand(DELIM); WPList.setCommandListener(this); } }

cxiv

Software Defects Prevention Techniques Example Project

MathFP.java
All classes and interfaces must belong to a named package
All methods are static. Consider using Singleton instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.

11 PMD Marker 11 11 11 11 16 16 16 35 35 37 37 39 47 47 49 49 51 62 63 63 64 68 68 69 70 94 94 112 113 121 121 121 123 128 128 128 129 135 137 PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker PMD Marker

The class 'MathFP' has a Cyclomatic Complexity of 3 (Highest = 12). This class has too many methods, consider refactoring it. Weighted Methods per Class is 105 Avoid variables with short names like by Parameter 'by' is not assigned and could be declared final Parameter 'num' is not assigned and could be declared final Avoid variables with short names like l Parameter 'l' is not assigned and could be declared final
A method should have only one exit point, and that should be the last statement in the method

Avoid using if...else statements without curly braces Avoid using if...else statements without curly braces Avoid variables with short names like l Parameter 'l' is not assigned and could be declared final
A method should have only one exit point, and that should be the last statement in the method

Avoid using if...else statements without curly braces Avoid using if...else statements without curly braces Avoid variables with short names like e Avoid variables with short names like PI The field name indicates a constant but its modifiers do not The field name indicates a constant but its modifiers do not Lines of Code in Method is 19 Parameter 'i' is not assigned and could be declared final Avoid using if statements without curly braces
A method should have only one exit point, and that should be the last statement in the method A method should have only one exit point, and that should be the last statement in the method

Avoid using if...else statements without curly braces Local variable 'l1' could be declared final Avoid using if statements without curly braces Cyclomatic Complexity is 7 Lines of Code in Method is 22 Number of Statements is 31 Avoid using if statements without curly braces Avoid using for statements without curly braces MathFP.toFP(String) concatenates strings using + in a loop Prefer StringBuffer over += for concatenating strings Avoid using if statements without curly braces Avoid using if statements without curly braces Local variable 'l1' could be declared final

cxv

Zarko Acimovic

MathFP.java
Cyclomatic Complexity is 9 Lines of Code in Method is 29 Number of Statements is 26 The method 'mul' has a Cyclomatic Complexity of 12. The method mul() has an NPath complexity of 320
A method should have only one exit point, and that should be the last statement in the method

Cyclomatic Complexity is 8 Lines of Code in Method is 21 The method 'div' has a Cyclomatic Complexity of 11. Cyclomatic Complexity is 5
The String literal "Bad Input" appears 4 times in this file; the first occurrence is on 268

Avoid using for statements without curly braces Lines of Code in Method is 16 Number of Statements is 29 Consider simply returning the value vs storing it in local variable 'l5' Cyclomatic Complexity is 8 Lines of Code in Method is 31 Number of Statements is 33 The method 'exp' has a Cyclomatic Complexity of 10. Avoid using for statements without curly braces Cyclomatic Complexity is 8 Lines of Code in Method is 28 Number of Statements is 28 Avoid unused local variables such as 'l2'. The local variable l2 is never read Avoid if (x != y) ..; else ..; Cyclomatic Complexity is 5 Lines of Code in Method is 18

199 199 199 199 199 204 229 229 229 266 268 272 286 286 300 336 336 336 336 343 368 368 368 372 372 390 397 397

Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker Metrics Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker Java Problem PMD Marker Metrics Marker Metrics Marker

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

/** * MathFP implements fix point as a replacement for floating point */

// Processed by NMI's Java Code Viewer 4.8.1 1997-2000 B. Lemaire // Website: http://njcv.htmlplanet.com E-mail: info@njcv.htmlplanet.com // Copy registered to Evaluation Copy public class MathFP { /** Modulo (% operator) implementaition missing in MathFP 2.0.6 * @author BMa */

cxvi

Software Defects Prevention Techniques Example Project

16 public static long mod(long num, long by) { 17 //System.out.println("mod: "+MathFP.toString(num)+" by: "+MathFP.toString(by)); 18 long frac = MathFP.div(num, by); 19 //System.out.println("MathFP.div(num, by): "+MathFP.toString(MathFP.div(num, by))); 20 //long frac = MathFP.round(frac, 0); does not work properly??? 21 //System.out.println("MathFP.round(MathFP.div(num, by), 0): "+MathFP.toString(MathFP.round(MathFP.div(num, by), 0))); 22 frac = MathFP.toFP(MathFP.toLong(frac)); 23 //System.out.println("MathFP.better(MathFP.div(num, by), 0): "+MathFP.toString(frac)); 24 //System.out.println("MathFP.mul(by, frac): "+MathFP.toString(MathFP.mul(by, frac))); 25 //System.out.println("MathFP.mod: "+MathFP.toString(num MathFP.mul(by, frac))); 26 return num - MathFP.mul(by, frac); 27 } 28 29 30 //private static long sinLimit=toFP("0.0055"); 31 32 /** Fix of bad sin() in MathFP 2.0.6 - X is closer to real sin(X) than calculated value for small X 33 * @author BMa 34 */ 35 public static long sin(long l) { 36 if (abs(l) > toFP("0.0055")) 37 return sinBad(l); 38 else 39 return l; 40 } 41 42 //private static long asinLimit=toFP("0.019"); 43 44 /** Fix of bad asin() in MathFP 2.0.6 - X is closer to real asin(X) than calculated value for small X 45 * @author BMa 46 */ 47 public static long asin(long l) { 48 if (abs(l) > toFP("0.019")) 49 return asinBad(l); 50 else 51 return l; 52 } 53 54 55 private static int _fbits = 24; 56 private static int _digits = 8; 57 private static long _one; 58 private static long _fmask = 0xffffffL;
cxvii

Zarko Acimovic

59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

private static long _dmul = 0x5f5e100L; private static long _flt = 0L; private static long _pi; private static long e[]; public static long PI; public static long E; public static final long MAX_VALUE = 0x7fffffffffffffffL; public static final long MIN_VALUE = 0x8000000000000001L; public static int setPrecision(int i) { if(i > 24 || i < 0) return _digits; _fbits = i; _one = 1L << i; _flt = 24 - i; _digits = 0; _dmul = 1L; _fmask = _one - 1L; PI = _pi >> (int)_flt; E = e[1] >> (int)_flt; for(long l = _one; l != 0L;) { l /= 10L; _digits++; _dmul *= 10L; } return _digits; } public static int getPrecision() { return _fbits; } public static long toLong(long l) { if(l < 0L) return -(round(-l, 0) >> _fbits); else return round(l, 0) >> _fbits; } public static long toLongZare(long i) { if(i >= 0) i += 2048; else i -= 2048; return i >> 12; } public static long toFP(long l) { return l << _fbits; }
cxviii

Software Defects Prevention Techniques Example Project

110 111 public static long convert(long l, int i) { 112 long l1 = l >= 0L ? 1L : -1L; 113 if(abs(i) < 25L) 114 if(_fbits < i) 115 l = l + l1 * (1L << (i - _fbits >> 1)) >> i - _fbits; 116 else 117 l <<= _fbits - i; 118 return l; 119 } 120 121 public static long toFP(String s) { 122 int i = 0; 123 if(s.charAt(0) == '-') 124 i = 1; 125 String s1 = "-1"; 126 int j = s.indexOf(46); 127 if(j >= 0) { 128 for(s1 = s.substring(j + 1, s.length()); s1.length() < _digits; s1 = s1 + "0"); 129 if(s1.length() > _digits) 130 s1 = s1.substring(0, _digits); 131 } else { 132 j = s.length(); 133 } 134 long l = 0L; 135 if(i != j) 136 l = Long.parseLong(s.substring(i, j)); 137 long l1 = Long.parseLong(s1) + 1L; 138 long l2 = (l << _fbits) + (l1 << _fbits) / _dmul; 139 if(i == 1) 140 l2 = -l2; 141 return l2; 142 } 143 144 public static String toString(long l) { 145 boolean flag = false; 146 if(l < 0L) { 147 flag = true; 148 l = -l; 149 } 150 long l1 = l >> _fbits; 151 long l2 = _dmul * (l & _fmask) >> _fbits; 152 String s; 153 for(s = Long.toString(l2); s.length() < _digits; s = "0" + s); 154 return (flag ? "-" : "") + Long.toString(l1) + "." + s; 155 } 156 157 public static String toString(long l, int i) { 158 if(i > _digits) 159 i = _digits;
cxix

Zarko Acimovic

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210

String s = toString(round(l, i)); return s.substring(0, (s.length() - _digits) + i); } public static long getWholePart(String s){ int end = s.indexOf('.'); s = s.substring(0,end); long wh = toFP(s); return wh; } /** public static long getWholePart(long l){ String s = toString(l); int end = s.indexOf('.'); s = s.substring(0,end); long wh = toFP(s); return wh; }*/ public static long max(long l, long l1) { return l >= l1 ? l : l1; } public static long min(long l, long l1) { return l1 >= l ? l : l1; } public static long round(long l, int i) { long l1 = 10L; for(int j = 0; j < i; j++) l1 *= 10L; l1 = div(toFP(5L), toFP(l1)); if(l < 0L) l1 = -l1; return l + l1; } public static long mul(long l, long l1) { boolean flag = false; int i = _fbits; long l2 = _fmask; if((l & l2) == 0L) return (l >> i) * l1; if((l1 & l2) == 0L) return l * (l1 >> i); if(l < 0L && l1 > 0L || l > 0L && l1 < 0L) flag = true; if(l < 0L) l = -l;
cxx

Software Defects Prevention Techniques Example Project

211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261

if(l1 < 0L) l1 = -l1; for(; max(l, l1) >= 1L << 63 - i; i--) { l >>= 1; l1 >>= 1; l2 >>= 1; } long l3 = (l >> i) * (l1 >> i) << i; long l4 = (l & l2) * (l1 & l2) >> i; l4 += (l & ~l2) * (l1 & l2) >> i; l3 = l3 + l4 + ((l & l2) * (l1 & ~l2) >> i) << _fbits - i; if(l3 < 0L) throw new ArithmeticException("Overflow"); else return flag ? -l3 : l3; } public static long div(long l, long l1) { boolean flag = false; int i = _fbits; if(l1 == _one) return l; if((l1 & _fmask) == 0L) return l / (l1 >> i); if(l < 0L && l1 > 0L || l > 0L && l1 < 0L) flag = true; if(l < 0L) l = -l; if(l1 < 0L) l1 = -l1; for(; max(l, l1) >= 1L << 63 - i; i--) { l >>= 1; l1 >>= 1; } long l2 = (l << i) / l1 << _fbits - i; return flag ? -l2 : l2; } public static long add(long l, long l1) { return l + l1; } public static long sub(long l, long l1) { return l - l1; } public static long abs(long l) { if(l < 0L) return -l;
cxxi

Zarko Acimovic

262 else 263 return l; 264 } 265 266 public static long sqrt(long l, int i) { 267 if(l < 0L) 268 throw new ArithmeticException("Bad Input"); 269 if(l == 0L) 270 return 0L; 271 long l1 = l + _one >> 1; 272 for(int j = 0; j < i; j++) 273 l1 = l1 + div(l, l1) >> 1; 274 275 if(l1 < 0L) 276 throw new ArithmeticException("Overflow"); 277 else 278 return l1; 279 } 280 281 public static long sqrt(long l) { 282 return sqrt(l, 24); 283 } 284 285 //public static long sin(long l) { 286 private static long sinBad(long l) { 287 long l1 = mul(l, div(toFP(180L), PI)); 288 l1 %= toFP(360L); 289 if(l1 < 0L) 290 l1 = toFP(360L) + l1; 291 long l2 = l1; 292 if(l1 >= toFP(90L) && l1 < toFP(270L)) 293 l2 = toFP(180L) - l1; 294 else 295 if(l1 >= toFP(270L) && l1 < toFP(360L)) 296 l2 = -(toFP(360L) - l1); 297 long l3 = l2 / 90L; 298 long l4 = mul(l3, l3); 299 long l5 = mul(mul(mul(mul(0xfffffffffffee21aL >> (int)_flt, l4) + (0x14594dL >> (int)_flt), l4) - (0xa55b13L >> (int)_flt), l4) + (long)(0x1921f9c >> (int)_flt), l3); 300 return l5; 301 } 302 303 //public static long asin(long l) { 304 private static long asinBad(long l) { 305 if(abs(l) > _one) { 306 throw new ArithmeticException("Bad Input"); 307 } else { 308 boolean flag = l < 0L; 309 l = abs(l);

cxxii

Software Defects Prevention Techniques Example Project

310 long l1 = mul(mul(mul(mul(0x236cf >> (int)_flt, l) - (long)(0x92748 >> (int)_flt), l) + (long)(0x15acb4 >> (int)_flt), l) - (long)(0x36d0dd >> (int)_flt), l) + (long)(0x1921f27 >> (int)_flt); 311 long l2 = PI / 2L - mul(sqrt(_one - l), l1); 312 return flag ? -l2 : l2; 313 } 314 } 315 316 public static long cos(long l) { 317 return sin(PI / 2L - l); 318 } 319 320 public static long acos(long l) { 321 return PI / 2L - asin(l); 322 } 323 324 public static long tan(long l) { 325 return div(sin(l), cos(l)); 326 } 327 328 public static long cot(long l) { 329 return div(cos(l), sin(l)); 330 } 331 332 public static long atan(long l) { 333 return asin(div(l, sqrt(_one + mul(l, l)))); 334 } 335 336 public static long exp(long l) { 337 if(l == 0L) 338 return _one; 339 boolean flag = l < 0L; 340 l = abs(l); 341 int i = (int)(l >> _fbits); 342 long l1 = _one; 343 for(int j = 0; j < i / 4; j++) 344 l1 = mul(l1, e[4] >> (int)_flt); 345 346 if(i % 4 > 0) 347 l1 = mul(l1, e[i % 4] >> (int)_flt); 348 l &= _fmask; 349 if(l > 0L) { 350 long l2 = _one; 351 long l3 = 0L; 352 long l4 = 1L; 353 for(int k = 0; k < 16; k++) { 354 l3 += l2 / l4; 355 l2 = mul(l2, l); 356 l4 *= k + 1; 357 if(l4 > l2 || l2 <= 0L || l4 <= 0L) 358 break;
cxxiii

Zarko Acimovic

359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409

} l1 = mul(l1, l3); } if(flag) l1 = div(_one, l1); return l1; } public static long log(long l) { if(l <= 0L) throw new ArithmeticException("Bad Input"); long l1 = 0L; long l2 = 0L; int i; for(i = 0; l >= _one << 1; i++) l >>= 1; long l4 = (long)i * (long)(0xb17218 >> (int)_flt); long l5 = 0L; if(l < _one) return -log(div(_one, l)); l -= _one; for(int j = 1; j < 20; j++) { long l3; if(l1 == 0L) l3 = l; else l3 = mul(l1, l); if(l3 == 0L) break; l5 += ((j % 2 != 0 ? 1L : -1L) * l3) / (long)j; l1 = l3; } return l4 + l5; } public static long pow(long l, long l1) { boolean flag = l1 < 0L; long l2 = _one; l1 = abs(l1); for(int i = (int)l1 >> _fbits; i-- > 0;) l2 = mul(l2, l); if(l2 < 0L) throw new ArithmeticException("Overflow"); if(l != 0L) l2 = mul(l2, exp(mul(log(l), l1 & _fmask))); else l2 = 0L;
cxxiv

Software Defects Prevention Techniques Example Project

410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

if(flag) return div(_one, l2); else return l2; } public static long atan2(long l, long l1) { long l2 = 0L; if(l1 > 0L) l2 = atan(div(l, l1)); else if(l1 < 0L) { l2 = (l1 >= 0L ? PI : -PI) - atan(abs(div(l, l1))); } else { if(l1 == 0L && l == 0L) throw new ArithmeticException("Bad Input"); l2 = (l >= 0L ? PI : -PI) / 2L; } return l2; } static { _one = 0x1000000L; _pi = 0x3243f6aL; e = (new long[] { _one, 0x2b7e151L, 0x763992eL, 0x1415e5bfL, 0x3699205cL }); PI = _pi; E = e[1]; } }

cxxv

Zarko Acimovic

Outlook.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 82% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 66% Lack of Cohesion in Methods (Total Correlation) is 353% The class 'Outlook' has a Cyclomatic Complexity of 2 (Highest = 10). Avoid variables with short names like mb
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Unused field: Outlook.mbf Use explicit scoping instead of the default package private level
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level
Found non-transient, non-static member. Please mark as transient or provide accessors. Found non-transient, non-static member. Please mark as transient or provide accessors.

Avoid variables with short names like mb Avoid variables with short names like sp Parameter 'mb' is not assigned and could be declared final Parameter 'mob' is not assigned and could be declared final Parameter 'sp' is not assigned and could be declared final Avoid variables with short names like g Cyclomatic Complexity is 6 Lines of Code in Method is 33 Number of Statements is 21 Parameter 'g' is not assigned and could be declared final The method 'drawOutlook' has a Cyclomatic Complexity of 10. Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Avoid using if statements without curly braces Avoid using if statements without curly braces Local variable 'zoom' could be declared final The method name Outlook.ZoomIn() doesn't start with a lower case letter Avoid using if statements without curly braces Local variable 'zoom' could be declared final

10 10 10 10 10 11 11 11 12 12 13 13 14 14 15 16 17 22 22 22 22 22 29 29 29 29 29 29 30 37 37 37 42 57 59 64 64 65 69

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker

cxxvi

Software Defects Prevention Techniques Example Project

1 /** 2 * 3 * Outlook coordinates work MapBackground, MapObjects and SelectorPoint 4 * 5 */ 6 //import java.util.*; 7 //import java.io.*; 8 import javax.microedition.lcdui.*; 9 10 public class Outlook { 11 MapBackground mb; 12 MapObjects mob; 13 MapBackgroundFactory mbf; 14 SelectorPoint selP; 15 boolean select = false; 16 boolean route = false; 17 boolean startup = false; 18 boolean first = false; 19 Point center = new Point("44.83168","20.445","","","blanco",false); 20 boolean WPselection = false; 21 22 Outlook(MapBackground mb, MapObjects mob, SelectorPoint sp) { 23 24 this.mb = mb; 25 this.mob = mob; 26 this.selP = sp; 27 } 28 29 public void drawOutlook(Graphics g){ 30 if(startup==false) { 31 mb.setBackground(center); 32 startup = true; 33 } 34 35 mb.drawMapBackground(g); 36 37 if(first==true && mob.currentSet()==false && WPselection==false){ 38 selP.selP = new Point(mb.getNewEdge(),false); 39 first=false; 40 } 41 42 if(first==true && mob.currentSet()==true && WPselection==false){ 43 selP.selectWP(mob.getCurrentPosition().getName()); 44 mb.drawMapBackground(g); 45 first=false; 46 } 47 48 /**
cxxvii

Zarko Acimovic

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

if(route==false){ mob.drawMOB(g,route); if(select==true) selP.drawSelP(g); } else { if(select==true) selP.drawSelP(g); mob.drawMOB(g,route); }*/ if(select==true) selP.drawSelP(g); mob.drawMOB(g,route); if(select==true) selP.drawCaption(g); } public void ZoomIn(){ boolean zoom = mb.ZoomIn(); if(zoom==true) selP.Zoom(); } public void ZoomOut(){ boolean zoom = mb.ZoomOut(); if(zoom==true) selP.Zoom(); } /** Sets map due to Pan transformation */ public void setMap(char side){ if(select == false) mb.setMap(side); if(select == true) selP.setSelectorScreen(side); } public void setCanvasWH(int cW,int cH){ mb.setCanvasWH(cW,cH); } public void setSelect(){ select = true; first = true; //selP.resetBig(); } public void setWPselection(){ WPselection = true; } public void resetSelect(){ select = false; WPselection = false; } public boolean getSelect(){
cxxviii

Software Defects Prevention Techniques Example Project

100 101 102 103 104 105 106 107 108 109 110 111 112

return select; } public void setRoute(){ route = true; } public void resetRoute(){ route = false; }

cxxix

Zarko Acimovic

Point.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Chidamber & Kemerer) is 309 Lack of Cohesion in Methods (Henderson-Sellers) is 91% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 80% Lack of Cohesion in Methods (Total Correlation) is 474% Number of Fields is 21 The class 'Point' has a Cyclomatic Complexity of 2 (Highest = 13). Too many fields Weighted Methods per Class is 60 Avoid variables with short names like ID
Found non-transient, non-static member. Please mark as transient or provide accessors.

The field name indicates a constant but its modifiers do not Possible unsafe assignment to a non-final static field in a constructor.
Found non-transient, non-static member. Please mark as transient or provide accessors. Private field 'degLat' could be made final; it is only initialized in the declaration or constructor. Found non-transient, non-static member. Please mark as transient or provide accessors. Private field 'minLat' could be made final; it is only initialized in the declaration or constructor. Found non-transient, non-static member. Please mark as transient or provide accessors. Private field 'secLat' could be made final; it is only initialized in the declaration or constructor. Found non-transient, non-static member. Please mark as transient or provide accessors. Private field 'degLon' could be made final; it is only initialized in the declaration or constructor. Private field 'minLon' could be made final; it is only initialized in the declaration or constructor.

Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Avoid variables with short names like x Avoid variables with short names like y Unread field: Point.dm1 Use explicit scoping instead of the default package private level Unread field: Point.dm2 Avoid variables with short names like rr Unread field: Point.rr Lines of Code in Method is 36 Number of Parameters is 9 Number of Statements is 36 Parameter 'dlat' is not assigned and could be declared final Parameter 'mlat' is not assigned and could be declared final Parameter 'slat' is not assigned and could be declared final Parameter 'dlon' is not assigned and could be declared final Parameter 'mlon' is not assigned and could be declared final

10 10 10 10 10 10 10 10 10 25 25 25 30 44 44 48 48 52 52 63 63 67 79 83 87 91 99 103 108 108 112 116 116 123 123 123 126 126 126 127 127

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker FindBugs PMD Marker FindBugs Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

cxxx

Software Defects Prevention Techniques Example Project

Point.java
Number of Parameters is 5 Number of Statements is 58 Local variable 'latS' could be declared final Local variable 'lonS' could be declared final Avoid unnecessary comparisons in boolean expressions
Write to static field Point.cnt from instance method new Point(long, long, String, String, boolean)

Lines of Code in Method is 29 Avoid unnecessary comparisons in boolean expressions


Write to static field Point.cnt from instance method new Point(Point, boolean)

Lines of Code in Method is 45 Number of Parameters is 6 Number of Statements is 57 Avoid unnecessary comparisons in boolean expressions
Write to static field Point.cnt from instance method new Point(String, String, String, String, String, boolean)

162 162 174 175 200 202 211 232 234 241 241 241 277 279 334 335 474 496 496 529 531 559 565 660 660 660 660 660 660 668 671

Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker FindBugs Metrics Marker PMD Marker FindBugs Metrics Marker Metrics Marker Metrics Marker PMD Marker FindBugs PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker

Local variable 'c1' could be declared final Local variable 'c2' could be declared final Lines of Code in Method is 21 Lines of Code in Method is 41 Number of Statements is 29 Avoid unnecessary if..then..else statements when returning a boolean
A method should have only one exit point, and that should be the last statement in the method

Consider simply returning the value vs storing it in local variable 'xx' Consider simply returning the value vs storing it in local variable 'yy' Cyclomatic Complexity is 12 Lines of Code in Method is 39 Number of Parameters is 5 Number of Statements is 76 The method 'drawPoint' has a Cyclomatic Complexity of 13. The method drawPoint() has an NPath complexity of 1032 Avoid using if statements without curly braces Avoid using if statements without curly braces

1 2 3 4 5 6 7 8 9 10 11 12

/** * Class Point represents geographical object */

//import java.util.*; //import java.io.*; import javax.microedition.lcdui.*; public class Point {

cxxxi

Zarko Acimovic

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

/** type of Waypoint * -2 - destination Point * -1 - current Point * 0 - free Point * n - route Point */ private int typeID = 0;

/** Point ID * */ private int ID = 0;

/** Counter */ private static int cnt = 0;

/** Float-point representation of latitude */ private long lat; /** Float-point representation of longitude */ private long lon;

/** Degrees of latitude in Integer */ private long degLat; /** Minutes of latitude in Integer */ private long minLat; /** Seconds of latitude in Integer */ private long secLat; /** Side of the world, South or North */ //private char sideNS;

/** Degrees of longitude in Integer */ private long degLon;


cxxxii

Software Defects Prevention Techniques Example Project

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

/** Minutes of longitude in Integer */ private long minLon; /** Seconds of longitude in Integer */ private long secLon; /** Side of the world, West or East */ //private char sideWE; /** Total number of latitude seconds */ long totLatSec; /** Total number of longitude seconds */ long totLonSec; /** Name of the Point */ String name = "default"; /** Type of the Point */ String type = "default"; /** Distance between this point and point which asks sorting */ private long distance; /** x coordinate of Point on Canvas */ private long x = 5; /** y coordinate of Point on Canvas */ private long y = 5;

/** Help variable */ long dm1=0; /** Help variable */ long dm2=0; /** Help variable
cxxxiii

Zarko Acimovic

115 */ 116 long rr=1000; 117 118 /** String that describes image 119 */ 120 String imgString = "blanco"; 121 122 123 /** Regular constructor 124 * @author Zarko Acimovic 125 */ 126 Point(long dlat, long mlat, long slat, //char side1, 127 long dlon, long mlon, long slon, //char side2, 128 String n, String t,boolean setNewID){ 129 130 degLat=MathFP.toFP(dlat); 131 minLat=MathFP.toFP(mlat); 132 secLat=MathFP.toFP(slat); 133 //sideNS=side1; 134 135 136 degLon=MathFP.toFP(dlon); 137 minLon=MathFP.toFP(mlon); 138 secLon=MathFP.toFP(slon); 139 //sideWE=side2; 140 141 name=n; 142 type=t; 143 144 long sixty=MathFP.toFP("60"); 145 146 lat = MathFP.add(degLat,MathFP.div(MathFP.add(minLat,MathFP.div(secLat,sixty)),sixty)); 147 lon = MathFP.add(degLon,MathFP.div(MathFP.add(minLon,MathFP.div(secLon,sixty)),sixty)); 148 149 totLatSec = MathFP.mul(lat,MathFP.toFP("3600")); 150 totLonSec = MathFP.mul(lon,MathFP.toFP("3600")); 151 152 if(setNewID==true){ 153 ID = cnt; 154 cnt++; 155 } 156 typeID = 0; //default type 157 //System.out.println("cnt="+cnt); 158 } 159 160 161 162 Point(long totLatSec, 163 //char s1,
cxxxiv

Software Defects Prevention Techniques Example Project

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

long totLonSec, //char s2, String ss1, String ss2, boolean setNewID){ lat = MathFP.div(totLatSec, MathFP.toFP("3600")); lon = MathFP.div(totLonSec, MathFP.toFP("3600")); this.name = ss1; this.type = ss2; //this.sideNS = s1; //this.sideWE = s2; String latS = MathFP.toString(lat); String lonS = MathFP.toString(lon); this.degLat = MathFP.getWholePart(latS); long temp = MathFP.sub(this.lat,this.degLat); temp = MathFP.mul(temp,MathFP.toFP("60")); this.minLat = MathFP.getWholePart(MathFP.toString(temp)); temp = MathFP.sub(this.lat,this.degLat); temp = MathFP.mul(temp,MathFP.toFP("60")); temp = MathFP.sub(temp,minLat); this.secLat = MathFP.mul(temp,MathFP.toFP("60")); this.degLon = MathFP.getWholePart(lonS); temp = MathFP.sub(this.lon,this.degLon); temp = MathFP.mul(temp,MathFP.toFP("60")); this.minLon = MathFP.getWholePart(MathFP.toString(temp)); temp = MathFP.sub(this.lon,this.degLon); temp = MathFP.mul(temp,MathFP.toFP("60")); temp = MathFP.sub(temp,minLon); this.secLon = MathFP.mul(temp,MathFP.toFP("60")); this.totLatSec = totLatSec; this.totLonSec = totLonSec; if(setNewID==true){ ID = cnt; cnt++; } typeID = 0; //default type //System.out.println("cnt="+cnt); }

Point(Point wp, boolean setNewID) { degLat=wp.degLat; minLat=wp.minLat; secLat=wp.secLat;


cxxxv

Zarko Acimovic

215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

//sideNS=wp.sideNS;

degLon=wp.degLon; minLon=wp.minLon; secLon=wp.secLon; //sideWE=wp.sideWE; name=wp.name; type=wp.type; this.lat = wp.lat; this.lon = wp.lon; this.totLatSec = wp.totLatSec; this.totLonSec = wp.totLonSec;

if (setNewID==true){ ID = cnt; cnt++; } typeID = 0; //default type //System.out.println("cnt="+cnt); imgString = wp.getImage(); } Point (String lat, //char sideNS, String lon, //char sideWE, String name, String type, String img, boolean setNewID){ //this.sideNS = sideNS; //this.sideWE = sideWE; this.name = name; this.type = type; this.lat = MathFP.toFP(lat); this.lon = MathFP.toFP(lon); this.degLat = MathFP.getWholePart(lat); long temp = MathFP.sub(this.lat,this.degLat); temp = MathFP.mul(temp,MathFP.toFP("60")); this.minLat = MathFP.getWholePart(MathFP.toString(temp)); temp = MathFP.sub(this.lat,this.degLat); temp = MathFP.mul(temp,MathFP.toFP("60")); temp = MathFP.sub(temp,minLat); this.secLat = MathFP.mul(temp,MathFP.toFP("60")); this.degLon = MathFP.getWholePart(lon); temp = MathFP.sub(this.lon,this.degLon); temp = MathFP.mul(temp,MathFP.toFP("60"));
cxxxvi

Software Defects Prevention Techniques Example Project

266 this.minLon = MathFP.getWholePart(MathFP.toString(temp)); 267 268 temp = MathFP.sub(this.lon,this.degLon); 269 temp = MathFP.mul(temp,MathFP.toFP("60")); 270 temp = MathFP.sub(temp,minLon); 271 this.secLon = MathFP.mul(temp,MathFP.toFP("60")); 272 273 this.totLatSec = MathFP.mul(this.lat,MathFP.toFP("3600")); 274 this.totLonSec = MathFP.mul(this.lon,MathFP.toFP("3600")); 275 276 277 if (setNewID==true) { 278 ID = cnt; 279 cnt++; 280 } 281 typeID = 0; //default type 282 //System.out.println("cnt="+cnt); 283 imgString = img; 284 285 } 286 287 288 289 /** 290 Point(String lat, String lon, String name, String type, String image, boolean setNewID){ 291 this.name = name; 292 this.type = type; 293 this.lat = MathFP.toFP(lat); 294 this.lon = MathFP.toFP(lon); 295 296 this.degLat = MathFP.getWholePart(lat); 297 long temp = MathFP.sub(this.lat,this.degLat); 298 temp = MathFP.mul(temp,MathFP.toFP("60")); 299 this.minLat = MathFP.getWholePart(MathFP.toString(temp)); 300 301 temp = MathFP.sub(this.lat,this.degLat); 302 temp = MathFP.mul(temp,MathFP.toFP("60")); 303 temp = MathFP.sub(temp,minLat); 304 this.secLat = MathFP.mul(temp,MathFP.toFP("60")); 305 306 this.degLon = MathFP.getWholePart(lon); 307 temp = MathFP.sub(this.lon,this.degLon); 308 temp = MathFP.mul(temp,MathFP.toFP("60")); 309 this.minLon = MathFP.getWholePart(MathFP.toString(temp)); 310 311 temp = MathFP.sub(this.lon,this.degLon); 312 temp = MathFP.mul(temp,MathFP.toFP("60")); 313 temp = MathFP.sub(temp,minLon); 314 this.secLon = MathFP.mul(temp,MathFP.toFP("60")); 315
cxxxvii

Zarko Acimovic

316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366

this.totLatSec = MathFP.mul(this.lat,MathFP.toFP("3600")); this.totLonSec = MathFP.mul(this.lon,MathFP.toFP("3600"));

if (setNewID==true) { ID = cnt; cnt++; } typeID = 0; //default type }*/ /** Calculates distance between two Points; * * @version advanced * @return long */ public long measureDistance(Point wp){ Coordinates c1 = new Coordinates(this.lat,this.lon); Coordinates c2 = new Coordinates(wp.lat, wp.lon); return MathFP.toLong(c1.distance(c2)); } /** Sets distance */ public void setDistance (long dist){ distance = dist; } /** Gets distance * @return long */ public long getDistance (){ return distance; } /** Returns type of Point * @return String */ public String getType() { return type; } /** Sets type of Point * @return String */ public void setType(String type) { this.type = type; } /** Returns name of Point * @return String */ public String getName() { return name; }

cxxxviii

Software Defects Prevention Techniques Example Project

367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417

/** Sets type of Point * @return String */ public void setName(String name) { this.name = name; } /** Returns side of the world as String * @return String * */ //public char getNS(){ // return sideNS; //} /** Returns side of the world as String * @return String * */ //public char getWE(){ // return sideWE; //} /** Returns degrees of latitiude * * @author Zarko Acimovic * @version initial */ public long getDLat(){ return degLat; } /** Returns minutes of latitiude * * @author Zarko Acimovic * @version initial */ public long getMLat(){ return minLat; } /** Returns seconds of latitiude * * @author Zarko Acimovic * @version initial */ public long getSLat(){ return secLat; } /** Returns degrees of longitude * * @author Zarko Acimovic
cxxxix

Zarko Acimovic

418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468

* @version initial */ public long getDLon(){ return degLon; } /** Returns minutes of longitude * * @author Zarko Acimovic * @version initial */ public long getMLon(){ return minLon; } /** Returns seconds of longitude * * @author Zarko Acimovic * @version initial * @return int */ public long getSLon(){ return secLon; } /** Returns latitude as floating point * * @author Zarko Acimovic * @version initial * @return Float-Point */ public long getLat(){ return lat; } /** Returns longitude as floating point * * @author Zarko Acimovic * @version initial * @return Float-Point */ public long getLon(){ return lon; } /** Prints Point * @author Zarko Acimovic * @version initial * @return String */ public String toString(){
cxl

Software Defects Prevention Techniques Example Project

469 return "ID="+getID()+"\n"+"Longitude: "+MathFP.toString(this.lon)+" "+MathFP.toString(this.degLon) +","+MathFP.toString(this.minLon)+","+MathFP.toString(this.secLon)+","+" x="+this.getX()+ 470 "\nLatitude: "+MathFP.toString(this.lat)+" "+MathFP.toString(this.degLat)+","+MathFP.toString(this.minLat) +","+MathFP.toString(this.secLat)+","+" y="+this.getY()+" "+this.getName()+"\n" 471 +this.getImage(); 472 } 473 474 /** Sets x and y coordinates on Canvas relative to wp 475 * Usually wp is newEdge 476 * @author Zarko Acimovic 477 * @version initial 478 */ 479 public void setXY (Point wp, long pixLon, long pixLat){ 480 //System.out.println("----this------------------"+this); 481 //System.out.println("-------newEdge---------------"+wp); 482 ///System.out.println("this.getLat()="+MathFP.toString(this.getLat())); 483 //System.out.println("this.getLon()="+MathFP.toString(this.getLon())); 484 ///System.out.println("wp.getLat()="+MathFP.toString(wp.getLat())); 485 ///System.out.println("wp.getLon()="+MathFP.toString(wp.getLon())); 486 //System.out.println("pixLat="+MathFP.toString(pixLat)); 487 ///System.out.println("pixLon="+MathFP.toString(pixLon)); 488 489 y = MathFP.div(MathFP.mul(MathFP.sub(wp.getLat(),this.getLat()),MathFP.toFP("3600")),pi xLat); 490 y = MathFP.toLong(y); 491 492 x = MathFP.div(MathFP.mul(MathFP.sub(this.getLon(),wp.getLon()),MathFP.toFP("3600")),pi xLon); 493 x = MathFP.toLong(x); 494 } 495 496 /** Checks if this Point is beetwen wp1 and wp2 497 * 498 * @version initial 499 * @return boolean 500 */ 501 public boolean check(Point wp1, Point wp2){ 502 503 long lim1Lat = wp1.getLat(); 504 long lim1Lon = wp1.getLon(); 505 long lim2Lat = wp2.getLat(); 506 long lim2Lon = wp2.getLon();
cxli

Zarko Acimovic

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557

long long long long

bigLat; miniLat; bigLon; miniLon;

if (lim1Lat>lim2Lat){ bigLat=lim1Lat; miniLat=lim2Lat; } else { bigLat=lim2Lat; miniLat=lim1Lat; } if (lim1Lon>lim2Lon){ bigLon=lim1Lon; miniLon=lim2Lon; } else { bigLon=lim2Lon; miniLon=lim1Lon; } if (miniLat<this.getLat() && this.getLat()<bigLat && miniLon<this.getLon() && this.getLon()<bigLon){ return true; } else { return false; } }

/** Returns x-position of Point on Canvas * * @author Zarko Acimovic * @version initial * @return long */ public long getX() {return x; } /** Returns y-position of Point on Canvas * * @author Zarko Acimovic * @version initial * @return long */ public long getY() {return y; } public int getXX() { Long l = new Long(x);
cxlii

Software Defects Prevention Techniques Example Project

558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608

int xx = Integer.parseInt(l.toString()); return xx; } public int getYY() { Long l = new Long(y); int yy = Integer.parseInt(l.toString()); return yy; } /** Adds inc on x */ public void addX(long inc ){ this.x+=inc; } /** Substracts dec from x */ public void subX(long dec){ this.x-=dec; } /** Adds inc on y */ public void addY(long inc){ this.y+=inc; } /** Substracts dec from y */ public void subY(long dec){ this.y-=dec; }

/** Returns total number of lat-seconds for Point * * @author Zarko Acimovic * @version initial * @return long */ public long getLatSec() { return totLatSec; } /** Returns total number of lon-seconds for Point * * @author Zarko Acimovic * @version initial * @return long */
cxliii

Zarko Acimovic

609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659

public long getLonSec() { return totLonSec; } /** Sets x-position of Point on screen */ public void setX(long x){ this.x=x; } /** Sets y-position of Point on screen */ public void setY(long y){ this.y=y; } /** Sets ID of Point * 0 - simple Point * 1 - current Point * 2 - destination Point */ public void setTypeID(int i){ typeID = i; } /** Returns ID of Point * 0 - simple Point * 1 - current Point * 2 - destination Point */ public int getTypeID(){ return typeID; } public int getID(){ return ID; }

/** String that represents image */ public void setImage(String s){ imgString = s; } /** Returns name of the image */ public String getImage(){ return imgString; }

cxliv

Software Defects Prevention Techniques Example Project

660 public void drawPoint(Graphics g, Point newEdge, long pixLat, long pixLon, long zoomLv){ 661 662 this.setXY(newEdge,pixLon,pixLat); 663 if(this.getImage().equals("route")){ 664 g.fillRect(this.getXX()-3,this.getYY()-3,6,6); 665 } 666 if(this.getImage().equals("blanco")){ 667 g.fillRect(this.getXX()-3,this.getYY()-3,6,6); 668 if (this.getName().equals("current")) 669 g.drawString(this.getName(),this.getXX()-25,this.getYY() +5,0); 670 671 if (this.getName().equals("dest")) 672 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 673 674 if (this.getName().equals("GPS.txt")) 675 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 676 677 if (this.getName().equals("Mika.txt")) 678 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 679 680 if (this.getName().equals("GPS")) 681 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 682 683 if (this.getName().equals("Mika")) 684 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 685 686 if (this.getName().equals("Str8")) 687 g.drawString(this.getName(),this.getXX()-18,this.getYY() +11,0); 688 } 689 690 if(!this.getImage().equals("blanco") && ! this.getImage().equals("route")){ 691 Image img = null; 692 try{ 693 img = Image.createImage(this.getImage()); 694 }catch(Exception e){} 695 g.drawImage(img,this.getXX()-3,this.getYY()-3,0); 696 //g.drawString(this.getName(),this.getXX()15,this.getYY()+11,0); 697 } 698 } 699 700 public void setLat(String s){
cxlv

Zarko Acimovic

701 702 703 704 705 706 707 708

lat = MathFP.toFP(s); } public void setLon(String s){ lon = MathFP.toFP(s); } }

cxlvi

Software Defects Prevention Techniques Example Project

PVector.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 75% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 100% Lack of Cohesion in Methods (Total Correlation) is 114% Weighted Methods per Class is 45 Avoid variables with short names like ID The field name indicates a constant but its modifiers do not Possible unsafe assignment to a non-final static field in a constructor. Use explicit scoping instead of the default package private level Parameter 'name' is not assigned and could be declared final Parameter 'route' is not assigned and could be declared final Avoid unnecessary comparisons in boolean expressions
Write to static field PVector.cnt from instance method new PVector(String, boolean)

Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Avoid variables with short names like v Consider replacing this Vector with the newer java.util.List Parameter 'route' is not assigned and could be declared final Parameter 'v' is not assigned and could be declared final Avoid unnecessary comparisons in boolean expressions
Write to static field PVector.cnt from instance method new PVector(Vector, boolean)

Lines of Code in Method is 25 Number of Statements is 23 Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Avoid variables with short names like wp Consider replacing this Vector with the newer java.util.List Parameter 'wp' is not assigned and could be declared final Local variable 'size' could be declared final Local variable 'whs' could be declared final Avoid variables with short names like ht Consider replacing this Hashtable with the newer java.util.Map Local variable 'ht' could be declared final Avoid instantiating new objects inside loops Avoid variables with short names like hp Local variable 'hp' could be declared final Consider replacing this Vector with the newer java.util.List Local variable 'sorted' could be declared final Use ArrayList instead of Vector Avoid instantiating new objects inside loops

11 11 11 11 11 17 17 18 22 26 26 29 31 37 37 37 37 37 37 40 42 53 53 60 60 60 60 60 61 64 68 68 68 70 72 72 74 74 74 75

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

cxlvii

Zarko Acimovic

PVector.java

Dead store to temp1 in PVector.sortDescending(Point) The local variable temp1 is never read Use ArrayList instead of Vector Use ArrayList instead of Vector Dead store to temp1 in PVector.sortDescending(Point) Avoid using for statements without curly braces Cyclomatic Complexity is 5 Lines of Code in Method is 26 Number of Statements is 26 Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Hashtable with the newer java.util.Map Avoid instantiating new objects inside loops Use ArrayList instead of Vector Avoid instantiating new objects inside loops Avoid using if statements without curly braces Prefer StringBuffer over += for concatenating strings PVector.toString() concatenates strings using + in a loop Cyclomatic Complexity is 5 Lines of Code in Method is 46 Number of Statements is 35 Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Use ArrayList instead of Vector Lines of Code in Method is 30 Number of Statements is 28 Avoid instantiating new objects inside loops Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty()
A method should have only one exit point, and that should be the last statement in the method

Document empty method A getX() method which returns a boolean should be named isX() Cyclomatic Complexity is 6 Lines of Code in Method is 28 Number of Levels is 5

107 107 107 108 109 110 114 114 114 120 120 127 129 133 135 136 150 150 155 155 155 162 162 163 212 212 228 232 233 248 289 293 293 293

FindBugs Java Problem PMD Marker PMD Marker FindBugs PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker

cxlviii

Software Defects Prevention Techniques Example Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

/** * * PVector enables drawing and sorting of points by name and distance */

import java.util.*; //import java.io.*; import javax.microedition.lcdui.*; public class PVector extends Vector { /** ID of WP Vector * 0 - simple Vector * 1 - route */ private int ID = 0; private static int cnt = 0; private String name =""; boolean visible = false;

PVector(String name,boolean route){ super(); if (route==true) { this.name = name; cnt++; ID = cnt; } else { ID = 0; } } PVector(Vector v, boolean route){ super(); if (route==true) { ID = cnt; cnt++; } else { ID = 0; } for (int i=0; i<v.size(); i++){ this.addElement(v.elementAt(i)); } }
cxlix

Zarko Acimovic

51 52 53 /** Returns vector of Points sorted by distance 54 * from Point wp in ascending order 55 * 56 * @version initial 57 * @return Vector 58 */ 59 60 public Vector sortAscending(Point wp){ 61 int size = this.size(); 62 long[] distances = new long [size]; 63 for (int i=0; i<size; i++) { 64 Point whs = (Point)this.elementAt(i); //from warehouse 65 distances[i]=whs.measureDistance(wp); 66 whs.setDistance(distances[i]); 67 } 68 Hashtable ht = new Hashtable(); 69 for (int i=0; i<size; i++){ 70 ht.put(new Long(distances[i]),this.elementAt(i)); 71 } 72 HeapSorter hp = new HeapSorter(); 73 hp.heapsort(distances); 74 Vector sorted = new Vector(); 75 for (int i=0;i<size;i++) sorted.addElement(ht.get(new Long(distances[i]))); 76 return sorted; 77 } 78 79 public String[] sortByName(){ 80 //System.out.println("wwwwww"); 81 //int size = this.size(); 82 //long[] firstChars = new long[size]; 83 //Hashtable ht = new Hashtable(); 84 String names[] = new String[this.size()]; 85 for(int i=0; i<this.size(); i++){ 86 Point whs = (Point) this.elementAt(i); 87 //firstChars[i] = (long) whs.getName().charAt(0); 88 //ht.put(new Long(firstChars[i]),this.elementAt(i)); 89 names[i]=whs.getName(); 90 } 91 HeapSorter hp = new HeapSorter(); 92 hp.heapsort(names); 93 //Vector sorted = new Vector(); 94 //for (int i=0;i<size;i++) sorted.addElement(ht.get(new Long(firstChars[i]))); 95 //System.out.println("wwwwww\n"+sorted); 96 return names; 97 }
cl

Software Defects Prevention Techniques Example Project

98 99 /** Returns vector of Points sorted by distance 100 * from WayPint wp in descending order 101 * 102 * @version initial 103 * @return Vector 104 */ 105 public Vector sortDescending(Point wp){ 106 int size = this.size(); 107 Vector temp1 = new Vector(); 108 Vector temp2 = new Vector(); 109 temp1 = this.sortAscending(wp); 110 for (int i=0; i<size;i++ ) temp2.addElement(temp2.elementAt(size-i)); 111 return temp2; 112 } 113 114 /** Return vector of specific Points of type 'type' 115 * sorted by distance in ascending order from Point wp 116 * 117 * @version initial 118 * @return Vector 119 */ 120 public Vector sortAscending (Point wp, String type){ 121 int size = this.size(); 122 long[] distances = new long [size]; 123 for (int i=0; i<size; i++){ 124 Point whs = (Point)this.elementAt(i); //from warehouse 125 distances[i]=wp.measureDistance(whs); 126 } 127 Hashtable ht = new Hashtable(); 128 for (int i=0; i<size; i++){ 129 ht.put(new Long(distances[i]),this.elementAt(i)); 130 } 131 HeapSorter hp = new HeapSorter(); 132 hp.heapsort(distances); 133 Vector sorted = new Vector(); 134 for (int i=0;i<size;i++) { 135 Point wpnt = (Point)ht.get(new Long(distances[i])); 136 if (wp.getType().equals(type)) sorted.addElement(wpnt); 137 } 138 return sorted; 139 } 140 141 /** Prints array of Points 142 * @version initial 143 * @return String 144 */ 145 public String toString(){
cli

Zarko Acimovic

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196

String str=""; int size = this.size(); for (int i=0; i<size; i++){ Point wp =(Point)this.elementAt(i); str += wp.toString(); } return str; } /**Returns all Points in rectangle * defined by wp1 and wp2 as points * of diagonal * * @version initial * @return Vector */ public Vector getPoints(Point wp1, Point wp2){ Vector v = new Vector(); long long long long long long long long lim1Lat lim1Lon lim2Lat lim2Lon bigLat; miniLat; bigLon; miniLon; = = = = wp1.getLat(); wp1.getLon(); wp2.getLat(); wp2.getLon();

if (lim1Lat>lim2Lat){ bigLat=lim1Lat; miniLat=lim2Lat; } else { bigLat=lim2Lat; miniLat=lim1Lat; } if (lim1Lon>lim2Lon){ bigLon=lim1Lon; miniLon=lim2Lon; } else { bigLon=lim2Lon; miniLon=lim1Lon; } for (int i=0; i<this.size();i++){ Point wp = (Point)this.elementAt(i); if (miniLat<wp.getLat() && wp.getLat()<bigLat && miniLon<wp.getLon() && wp.getLon()<bigLon){ v.addElement(wp); }
clii

Software Defects Prevention Techniques Example Project

197 } 198 //System.out.println("Vektor je\n"+v); 199 return v; 200 } 201 202 /** Merges two vectors 203 * 204 * @version initial 205 */ 206 public void mergeWith(Vector v){ 207 for (int i=0; i<v.size(); i++ ){ 208 this.addElement(v.elementAt(i)); 209 } 210 } 211 212 /** Deletes Point 213 * 214 * @author Zarko Acimovic 215 * @version initial 216 */ 217 public int deleteWP1(Point wp, int pixLat, int pixLon){ 218 //System.out.println("Unutar DELETE"); 219 //System.out.println(this.size()); 220 Vector toDelete = new Vector(); 221 long pixLat1 = MathFP.toLong(pixLat); 222 long pixLon1 = MathFP.toLong(pixLon); 223 224 for (int i=0; i<this.size(); i++){ 225 Point wp2 = (Point)this.elementAt(i); 226 if ( Math.abs(wp2.getLatSec()wp.getLatSec())<5*pixLat1 && 227 Math.abs(wp2.getLonSec()wp.getLonSec())<5*pixLon1 ){ 228 toDelete.addElement(new Integer(i)); 229 } 230 } 231 232 if(toDelete.size()>1 || toDelete.size()==0) { 233 return -1; 234 } 235 else { 236 Integer k = (Integer)toDelete.elementAt(0); 237 int c = k.intValue(); 238 this.removeElementAt(c); 239 return c; 240 } 241 } 242 243 /** Edits Point 244 * 245 * @author Zarko Acimovic
cliii

Zarko Acimovic

246 * @version not yet implemented 247 */ 248 public void editWP(Point wp){ 249 } 250 251 252 /** Sets ID of WPVector 253 * 0 - simple WPVector 254 * n - route 255 * 256 */ 257 public void setID(int i){ 258 ID = i; 259 } 260 261 /** Returns ID of WPVector 262 * 0 - simple WPVector 263 * 1 - route 264 */ 265 public int getID(){ 266 return ID; 267 } 268 269 /** Returns name WPVector 270 */ 271 public String getName(){ 272 return name; 273 } 274 275 /** Returns name WPVector 276 */ 277 public void setName(String s){ 278 name = s; 279 } 280 281 public void setVisible(){ 282 visible = true; 283 } 284 285 public void resetVisible(){ 286 visible = false; 287 } 288 289 public boolean getVisible(){ 290 return visible; 291 } 292 293 public void drawVector(Graphics g, boolean route, Point newEdge, long pixLon, long pixLat, long zoomL){ 294 /////System.out.println("route="+route); 295 /////System.out.println("routeVisible="+this.getVisible());
cliv

Software Defects Prevention Techniques Example Project

296 if(route==true){ 297 if(this.getVisible()==true){ 298 if(this.size()==1){ 299 Point wp1 = (Point) this.elementAt(0); 300 wp1.drawPoint(g,newEdge,pixLat,pixLon,zoomL); 301 } else { 302 for(int j=0; j<this.size()-1; j++){ 303 Point wp1 = (Point) this.elementAt(j); 304 Point wp2 = (Point) this.elementAt(j+1); 305 //wp1.setXY(newEdge,pixLon,pixLat); 306 //wp2.setXY(newEdge,pixLon,pixLat); 307 wp1.drawPoint(g,newEdge,pixLat,pixLon,zoomL); 308 wp2.drawPoint(g,newEdge,pixLat,pixLon,zoomL); 309 g.drawLine(wp1.getXX(),wp1.getYY(),wp2.getXX(),wp2.getYY()); 310 } 311 } 312 } 313 } else { 314 for(int i=0; i<this.size(); i++){ 315 Point wp = (Point) this.elementAt(i); 316 wp.drawPoint(g,newEdge,pixLat,pixLon,zoomL); 317 } 318 } 319 320 } 321 322 323 };

clv

Zarko Acimovic

SelectorPoint.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 75% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 78% Lack of Cohesion in Methods (Total Correlation) is 333% The class 'SelectorPoint' has a Cyclomatic Complexity of 4 (Highest = 19). Weighted Methods per Class is 72 Avoid variables with short names like mb
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like m
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like n
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like s Avoid variables with short names like mb Parameter 'mb' is not assigned and could be declared final Parameter 'mob' is not assigned and could be declared final Cyclomatic Complexity is 15 Lines of Code in Method is 75 Number of Statements is 82 Parameter 's' is not assigned and could be declared final The method 'setSelectorScreen' has a Cyclomatic Complexity of 19. The method setSelectorScreen() has an NPath complexity of 11025 Avoid using if statements without curly braces Avoid using if statements without curly braces Avoid using if statements without curly braces Avoid using if statements without curly braces Local variable 'WP' could be declared final Avoid unnecessary comparisons in boolean expressions
The String literal "selector" appears 4 times in this file; the first occurrence is on 89

Avoid unnecessary comparisons in boolean expressions Feature Envy is 5 Lines of Code in Method is 22 Parameter 'edge' is not assigned and could be declared final

8 8 8 8 8 8 9 9 9 10 10 11 11 12 12 12 13 13 13 14 18 18 18 25 25 25 27 27 27 31 49 61 74 87 89 89 93 103 103 108

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker

clvi

Software Defects Prevention Techniques Example Project

SelectorPoint.java
Cyclomatic Complexity is 15 Lines of Code in Method is 73 Number of Levels is 5 Number of Statements is 89 The method 'selectWP' has a Cyclomatic Complexity of 18. The method selectWP() has an NPath complexity of 7290 Avoid unused local variables such as 'idS'. The local variable idS is never read Avoid using if statements without curly braces Consider replacing this Vector with the newer java.util.List Avoid unnecessary comparisons in boolean expressions Avoid unnecessary comparisons in boolean expressions Cyclomatic Complexity is 13 Lines of Code in Method is 73 Number of Statements is 99 The method 'deleteWP' has a Cyclomatic Complexity of 17. The method deleteWP() has an NPath complexity of 5760 Consider replacing this Vector with the newer java.util.List Use ArrayList instead of Vector Avoid instantiating new objects inside loops Consider replacing this Vector with the newer java.util.List Use ArrayList instead of Vector Consider replacing this Vector with the newer java.util.List Avoid instantiating new objects inside loops Avoid unused local variables such as 'drt'. The local variable drt is never read Substitute calls to size() == 0 (or size() != 0) with calls to isEmpty() Cyclomatic Complexity is 5 Feature Envy is 6 Lines of Code in Method is 26 Number of Statements is 54 The method name SelectorPoint.Zoom() doesn't start with a lower case letter Lines of Code in Method is 95 Number of Statements is 22 Avoid unused local variables such as 'length'. The local variable length is never read 169 169 169 169 172 172 177 177 183 214 237 238 243 243 243 251 251 256 256 261 265 265 266 272 277 277 278 318 318 318 318 321 346 346 414 414 Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker Java Problem PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Java Problem PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker FindBugs Metrics Marker Metrics Marker PMD Marker Java Problem

clvii

Zarko Acimovic

1 /** 2 * SelectorPoint controls selection and identification of geographical object 3 */ 4 import java.util.*; 5 //import java.io.*; 6 import javax.microedition.lcdui.*; 7 8 public class SelectorPoint{ 9 MapBackground mb; 10 MapObjects mob; 11 Point selP; 12 int m = 255; 13 int n = 200; 14 int s = 0; 15 boolean colorSet=false; 16 boolean big = false; 17 18 SelectorPoint(MapBackground mb, MapObjects mob){ 19 20 this.selP = mob.getCurrentPosition(); 21 this.mb = mb; 22 this.mob = mob; 23 } 24 25 /** Sets selector point on Screen due to user's left/right , up/down commands 26 */ 27 public void setSelectorScreen(char s){ 28 29 30 if(s=='r'){ 31 if (selP.getX()>0 && selP.getX()<mb.getCanvasWidth()) selP.addX(5); 32 if (selP.getX()>mb.getCanvasWidth()-5) { 33 // calculation of (deg,min,sec) for Selector before panning 34 //dakle ja pre panovanja izracunam svetske koordinate selektora, 35 //da bi znao gde je on stvarno, pa kad panujem mapu (a samim 36 //tim i promenim njen newEdge onda odredjujem i relativni polozaj 37 //selektorske tacke u odnosu na taj newEdge (jasno je da pri panovanju mape 38 //nije doslo do promene svetskih koordinata selektora) 39 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 40 //Paning
clviii

Software Defects Prevention Techniques Example Project

41 42 43 map

mb.setMap(s); mob.setDrawablePoints(); //calculation of new Selector position on panned

44 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 45 46 } 47 } 48 if(s=='l'){ 49 if (selP.getX()>6) selP.subX(5); 50 if (selP.getX()<=6) { 51 // calculation of (deg,min,sec) for Selector before panning 52 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 53 //Paning 54 mb.setMap(s); 55 mob.setDrawablePoints(); 56 //calculation of new Selector position on panned map 57 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 58 } 59 } 60 if(s=='d'){ 61 if (selP.getY()>0 && selP.getY()<mb.getCanvasHeight()-5) selP.addY(5); 62 if (selP.getY()>=(mb.getCanvasHeight()-5)) { 63 //calculation of (deg,min,sec) for Selector before panning 64 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 65 //Paning 66 mb.setMap(s); 67 mob.setDrawablePoints(); 68 //calculation of new Selector position on panned map 69 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 70 71 } 72 } 73 if(s=='u'){ 74 if (selP.getY()>6) selP.subY(5); 75 if (selP.getY()<=6) { 76 //calculation of (deg,min,sec) for Selector before panning 77 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 78 //Paning
clix

Zarko Acimovic

79 80 81 map

mb.setMap(s); mob.setDrawablePoints(); //calculation of new Selector position on panned

82 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 83 84 } 85 } 86 87 Point WP = this.getSelectedWP(); 88 89 if (!WP.getName().equals("selector") && colorSet==false) { 90 setColor(); 91 setBig(); 92 } 93 if (WP.getName().equals("selector") && colorSet==true) { 94 resetColor(); 95 resetBig(); 96 } 97 //if (!WP.getImage().equals("blanco") && ! WP.getImage().equals("route") && big==false) setBig(); 98 //if ((WP.getImage().equals("blanco")|| WP.getImage().equals("route")) && big==true) resetBig(); 99 } 100 101 102 103 /** When selector is moved we only update its (x,y) 'descriptors', 104 * so when map has to be panned we need to find out (lat,lon) pair 105 * for selector on old screen and adjust its position (x',y') on new screen 106 * in a way that (lat,lon) is unchanged 107 */ 108 public void setSelectorWorld(Point edge, long pixLon, long pixLat){ 109 110 // pamtim trenutno x i y 111 long tx = selP.getX(); 112 long ty = selP.getY(); 113 114 // azuriram svetske kordinate 115 long dLatSec = MathFP.mul(pixLat,MathFP.toFP(selP.getY())); 116 long dLonSec = MathFP.mul(pixLon,MathFP.toFP(selP.getX())); 117 118 selP = new Point(MathFP.sub(edge.getLatSec(),dLatSec), 119 MathFP.add(edge.getLonSec(),dLonSec),"","",false); 120 121 // vracam trenutno x i y 122 selP.setX(tx); 123 selP.setY(ty);
clx

Software Defects Prevention Techniques Example Project

124 } 125 126 /** Returns copy of SELECTOR Point 127 * @return Point 128 */ 129 public Point getSelector(){ 130 this.setSelectorWorld(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 131 Point copy = new Point(selP,true); 132 133 copy.setName(""); 134 return copy; 135 } 136 137 /** Returns x-coordinate of selector 138 * @return long 139 */ 140 long getSelX(){ 141 return selP.getX(); 142 } 143 144 /** Returns y-coordinate of selector 145 * @return long 146 */ 147 long getSelY(){ 148 return selP.getY(); 149 } 150 151 /** Returns user selected Point 152 * @return Point 153 */ 154 public Point getSelectedWP(){ 155 Vector v = mob.getDrawablePoints(); 156 Point ret = new Point(0,0,"selector","s",false); 157 for(int i=0; i<v.size(); i++){ 158 Point fWhs = (Point) v.elementAt(i); 159 if( Math.abs(fWhs.getX()-selP.getX())<5 && 160 Math.abs(fWhs.getY()-selP.getY())<5 ) { 161 ret=fWhs; 162 i=1000; 163 } 164 } 165 return ret; 166 } 167 168 169 /** Returns user selected Point with name s 170 * @return Point 171 */ 172 public void selectWP(String s) { 173
clxi

Zarko Acimovic

174 int len = s.length(); 175 int blanco = s.indexOf('_'); 176 if(blanco!=-1){ 177 String idS = s.substring(blanco+1,len); 178 s = s.substring(0,blanco); 179 s = compact(s); 180 } 181 182 int blank = s.indexOf(' '); 183 if(blank!=-1 && s.substring(blank+1,s.length()).equals("current")) s = s.substring(0,blank); 184 185 Point look4 = null; 186 PVector freeWPV = mob.getFreeWaypoints(); 187 188 int k=-2; 189 for(int i=0; i<freeWPV.size(); i++){ 190 Point wp = (Point) freeWPV.elementAt(i); 191 if(s.equals(wp.getName())){ 192 k=i; 193 look4 = (Point) freeWPV.elementAt(k); 194 i=1000; 195 } 196 } 197 198 if(k==-2){ 199 Point cP = mob.getCurrentPosition(); 200 if(s.equals(cP.getName())) { 201 look4=cP; 202 k=-3; 203 } 204 } 205 if(k==-2){ 206 Point dP = mob.getDestinationPosition(); 207 if(s.equals(dP.getName())) { 208 look4=dP; 209 k=-4; 210 } 211 } 212 213 if(k==-2){ 214 Vector routes = mob.getRoutes(); 215 for(int i=0; i<routes.size(); i++){ 216 PVector rt = (PVector) routes.elementAt(i); 217 for(int j=0; j<rt.size(); j++){ 218 Point wp = (Point)rt.elementAt(j); 219 System.out.println(wp); 220 if(wp.getName().equals(s)){ 221 k=j; 222 look4=(Point)rt.elementAt(j); 223 i=1000;
clxii

Software Defects Prevention Techniques Example Project

224 j=1000; 225 } 226 } 227 } 228 } 229 230 this.selP = new Point(look4,false); 231 232 mb.setBackground(look4); 233 234 mob.setDrawablePoints(); 235 selP.setXY(mb.getNewEdge(),mb.getPixLon(), mb.getPixLat()); 236 237 if (!selP.getImage().equals("blanco") && big==false) setBig(); 238 if (selP.getImage().equals("blanco") && big==true) resetBig(); 239 240 this.setColor(); 241 } 242 243 /** Deletes selected Point 244 * Returns -4 if current Point is deleted 245 * Returns -3 if destination Point is deleted 246 * Returns -2 if free Point deleted 247 * Returns -1 if more then one Point is selected 248 * Returns 0 if none Point is selected 249 * Returns n if n-th Point in route deleted 250 */ 251 public int deleteWP(){ 252 int ret = 0; 253 254 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 255 256 Vector temp1 = new Vector(); 257 PVector fWP = mob.getFreeWaypoints(); 258 for (int i=0; i<fWP.size(); i++){ 259 Point fwp = (Point)fWP.elementAt(i); 260 if( Math.abs(selP.getX()-fwp.getX())<5 && Math.abs(selP.getY()-fwp.getY())<5 ){ 261 temp1.addElement(new Integer(i)); 262 } 263 } 264 265 Vector temp2 = new Vector(); 266 Vector Routes = mob.getRoutes(); 267 for (int j=0; j<Routes.size(); j++){ 268 PVector vR = (PVector) Routes.elementAt(j); 269 for (int k=0; k<vR.size(); k++){ 270 Point wpR = (Point)vR.elementAt(k); 271 if( Math.abs(selP.getX()-wpR.getX())<5 && Math.abs(selP.getY()-wpR.getY())<5 ) {
clxiii

Zarko Acimovic

272 temp2.addElement(new DelRoute(k,wpR.getTypeID())); 273 } 274 } 275 } 276 277 DelRoute drt = null; 278 if(temp2.size()>0){ 279 drt = (DelRoute) temp2.elementAt(0); 280 } 281 282 if ( (temp1.size()+temp2.size())> 1 ) ret=-1; 283 if ( (temp1.size()+temp2.size())==0 ) ret=0; 284 if ( temp1.size()==1 ) { 285 Integer k = (Integer) temp1.elementAt(0); 286 int d = k.intValue(); 287 fWP.removeElementAt(d); 288 ret=-2; 289 } 290 if( temp2.size()==1 ){ 291 DelRoute dr = (DelRoute) temp2.elementAt(0); 292 PVector vR = (PVector) Routes.elementAt(dr.getRouteID()-1); 293 vR.removeElementAt(dr.getIndex()); 294 ret=dr.getIndex(); 295 } 296 297 Point cp = mob.getCurrentPosition(); 298 if( Math.abs(selP.getX()-cp.getX())<5 && 299 Math.abs(selP.getY()-cp.getY())<5 ) { 300 mob.resetCurrentPosition(); 301 ret= -4; 302 } 303 304 Point dp = mob.getDestinationPosition(); 305 306 if( Math.abs(selP.getX()-dp.getX())<5 && 307 Math.abs(selP.getY()-dp.getY())<5 ) { 308 mob.resetDestinationPosition(); 309 ret= -3; 310 } 311 312 resetColor(); 313 314 return ret; 315 } 316 317 318 /** Action that must be taken with Selector when Zoom In/Out 319 */ 320 public void Zoom(){

clxiv

Software Defects Prevention Techniques Example Project

321 this.setSelectorWorld(mb.getPreviousEdge(), mb.getPreviousPixLon(),mb.getPreviousPixLat()); 322 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 323 while (selP.getX()>mb.getCanvasWidth()) { 324 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 325 mb.setMap('r'); 326 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 327 } 328 while (selP.getY()>mb.getCanvasHeight()) { 329 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 330 mb.setMap('d'); 331 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 332 } 333 while (selP.getX()<0){ 334 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 335 mb.setMap('l'); 336 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 337 } 338 while (selP.getY()<0) { 339 this.setSelectorWorld(mb.getNewEdge(), mb.getPixLon(),mb.getPixLat()); 340 mb.setMap('u'); 341 selP.setXY(mb.getNewEdge(),mb.getPixLon(),mb.getPixLat()); 342 } 343 } 344 345 346 /** Draws selector point 347 * 348 public void drawSelPOld(Graphics g){ 349 long zl = mb.getZoomLevel()+1; 350 Long zzl = new Long(zl); 351 int zoomL = Integer.parseInt(zzl.toString()); 352 g.setColor(0,0,0); 353 g.drawRect(selP.getXX()-6,selP.getYY()-3,12,6); 354 g.setColor(m,n,s); 355 g.fillRect(selP.getXX()-3,selP.getYY()-6,6,12); 356 g.setColor(0,0,0); 357 } 358 359 /** Draws selector point 360 * 361 public void drawSelPOld1(Graphics g){ 362 long zl = mb.getZoomLevel()+1; 363 Long zzl = new Long(zl); 364 int zoomL = Integer.parseInt(zzl.toString()); 365 g.setColor(m,n,s); 366 g.fillRect(selP.getXX()-8,selP.getYY()-4,16,8);
clxv

Zarko Acimovic

367 g.fillRect(selP.getXX()-4,selP.getYY()-8,8,16); 368 g.setColor(0,0,0); 369 g.drawRect(selP.getXX()-8,selP.getYY()-4,16,8); 370 g.drawRect(selP.getXX()-4,selP.getYY()-8,8,16); 371 g.setColor(m,n,s); 372 g.fillRect(selP.getXX()-7,selP.getYY()-3,15,7); 373 g.fillRect(selP.getXX()-3,selP.getYY()-7,7,15); 374 375 g.setColor(0,0,0); 376 377 378 } 379 380 /** Draws selector point 381 * 382 public void drawSelPobsolete(Graphics g){ 383 //long zl = mb.getZoomLevel()+1; 384 //Long zzl = new Long(zl); 385 //int zoomL = Integer.parseInt(zzl.toString()); 386 if(big==false){ 387 g.setColor(m,n,s); 388 g.fillRect(selP.getXX()-8,selP.getYY()-4,15,7); 389 g.fillRect(selP.getXX()-4,selP.getYY()-8,7,5); 390 g.setColor(0,0,0); 391 g.drawRect(selP.getXX()-8,selP.getYY()-4,15,7); 392 g.drawRect(selP.getXX()-4,selP.getYY()-8,7,15); 393 g.setColor(m,n,s); 394 g.fillRect(selP.getXX()-7,selP.getYY()-3,14,6); 395 g.fillRect(selP.getXX()-3,selP.getYY()-7,6,14); 396 } else { 397 g.setColor(m,n,s); 398 g.fillRect(selP.getXX()-13,selP.getYY()-5,33,16); 399 g.fillRect(selP.getXX()-5,selP.getYY()-13,16,22);///umesto 16,32 sad je 16,25 400 g.setColor(0,0,0); 401 g.drawRect(selP.getXX()-13,selP.getYY()-5,33,16); 402 g.drawRect(selP.getXX()-5,selP.getYY()-13,16,22);///umesto 16,32 sad je 16,25 403 g.setColor(m,n,s); 404 g.fillRect(selP.getXX()-12,selP.getYY()-4,32,15); 405 g.fillRect(selP.getXX()-4,selP.getYY()-12,15,22); 406 407 //g.drawString(selP.getName(),selP.getXX()-15,selP.getYY() +11,0); 408 } 409 g.setColor(0,0,0); 410 if (!this.getSelectedWP().getName().equals("selector")) g.drawString(this.getSelectedWP().getName(),this.getSelectedWP().getXX()15,this.getSelectedWP().getYY()+11,0); 411 }*/ 412
clxvi

Software Defects Prevention Techniques Example Project

413 public void drawSelP(Graphics g){ 414 int length=0; 415 416 //g.setColor(m,n,s); 417 g.setColor(255,180,0); 418 g.fillRect(selP.getXX()-8,selP.getYY()-4,15,7); 419 g.fillRect(selP.getXX()-4,selP.getYY()-8,7,5); 420 g.setColor(0,0,0); 421 g.drawRect(selP.getXX()-8,selP.getYY()-4,15,7); 422 g.drawRect(selP.getXX()-4,selP.getYY()-8,7,15); 423 //g.setColor(m,n,s); 424 g.setColor(255,180,0); 425 g.fillRect(selP.getXX()-7,selP.getYY()-3,14,6); 426 g.fillRect(selP.getXX()-3,selP.getYY()-7,6,14); 427 /** 428 if(big==true){ 429 g.setColor(m,n,s); 430 //g.drawRect(selP.getXX()-4,selP.getYY()-4,15,15); 431 //g.drawRect(selP.getXX()-5,selP.getYY()-5,17,17); 432 //g.drawRect(selP.getXX()-6,selP.getYY()-6,19,19); 433 String name = this.getSelectedWP().getName(); 434 length = name.length(); 435 g.fillRect(selP.getXX()-4*length-2,selP.getYY() +12,8*length+2,14); 436 } 437 g.setColor(0,0,0); 438 if (!this.getSelectedWP().getName().equals("selector")) g.drawString(this.getSelectedWP().getName(),selP.getXX()-4*length,selP.getYY() +13,0); 439 */ 440 } 441 442 public void drawCaption(Graphics g){ 443 int length=0; 444 if(big==true){ 445 g.setColor(m,n,s); 446 //g.drawRect(selP.getXX()-4,selP.getYY()-4,15,15); 447 //g.drawRect(selP.getXX()-5,selP.getYY()-5,17,17); 448 //g.drawRect(selP.getXX()-6,selP.getYY()-6,19,19); 449 String name = this.getSelectedWP().getName(); 450 length = name.length(); 451 g.fillRect(selP.getXX()-4*length-2,selP.getYY() +12,8*length+2,14); 452 //if (!this.getSelectedWP().getName().equals("selector")) g.drawString(this.getSelectedWP().getName(),selP.getXX()-4*length,selP.getYY() +13,0); 453 g.setColor(0,0,0); 454 if (!this.getSelectedWP().getName().equals("selector")) g.drawString(this.getSelectedWP().getName(),selP.getXX()-4*length,selP.getYY() +13,0); 455 }
clxvii

Zarko Acimovic

456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506

/** Sets current position */ public void setCurrent(MapObjects mob){ Point wp = this.getSelectedWP(); mob.setCurrentPosition(wp); } /** Sets destination position */ public void setDest(MapObjects mob){ Point wp = this.getSelectedWP(); mob.setDestinationPosition(wp); } public void setColorOld(){ s = 0; colorSet=true; } public void setColor(){ m=255; n=255; s=0; colorSet=true; } public void resetColorOld(){ s = 255; colorSet=false; } public void resetColor(){ m=255; n=180; s=0; colorSet=false; } public void setBig(){ big=true; } public void resetBig(){ big=false; }

clxviii

Software Defects Prevention Techniques Example Project

507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527

/** * * * */

Blanco characters are possible to occur in names of pictures; Integer representations of blanko characters are 9 and 32 Also, characters with integer representation between 0 and 33 can not be printed out in WSDD console, so I excluded them too public String compact(String s){ int k = s.length(); char[] d = s.toCharArray(); String ret = ""; for(int i=0; i<d.length; i++){ int temp = (int)d[i]; if(temp>32) ret+=d[i]; } int kk = ret.length(); if (kk!=k) System.out.println("Bugger is: "+s); return ret; }

SimpleTextForm.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 75% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 74% Lack of Cohesion in Methods (Total Correlation) is 154%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Parameter 'createChgr' is not assigned and could be declared final Avoid unnecessary comparisons in boolean expressions Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s

15 15 15 15 19 19 23 23 25 25 27 27 33 39 63 63 67 67 71

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

clxix

Zarko Acimovic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

/** * Simple text form */

import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

//import java.io.*; //import java.util.*;

public class SimpleTextForm extends Form{ /** Name of waypoint */ TextField nameWP; /** Type of waypoint */ TextField typeWP; String[] str = new String[2]; ChoiceGroup chgr;

/** Creates new form */ SimpleTextForm(boolean createChgr){ super("Data Input"); nameWP = new TextField("Name","",8,0); typeWP = new TextField("Type","",8,0); this.append(nameWP); this.append(typeWP); if(createChgr==true){ str[0] = "Sysnchronized Following"; str[1] = "Out of Sync"; chgr = new ChoiceGroup("",1,str,null); this.append(chgr); } } /** Returns the name of waypoint * @return String */
clxx

Software Defects Prevention Techniques Example Project

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

public String getName(){ return nameWP.getString(); } /** Returns the type of waypoint * @return String */ public String getType(){ return typeWP.getString(); } /** Sets the name of waypoint */ public void setName(String s){ nameWP.setString(s); } public void setLabel(String s){ nameWP.setLabel(s); } public void setLabel2(String s){ typeWP.setLabel(s); } /** Sets the type of waypoint */ public void setType(String s){ typeWP.setString(s); } public int getSelected(){ return chgr.getSelectedIndex(); } }

clxxi

Zarko Acimovic

TextForm.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 80% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 81% Lack of Cohesion in Methods (Total Correlation) is 165%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Use explicit scoping instead of the default package private level Lines of Code in Method is 30 Avoid unused constructor parameters such as 'first'. Avoid variables with short names like s Parameter 's' is not assigned and could be declared final The user-supplied array 's' is stored directly. The user-supplied array 's' is stored directly. Avoid assignments in operands Dead store to first in new TextForm(String[], boolean) new TextForm(String[], boolean) assigns boolean literal in boolean expression
The parameter first to new TextForm(String[], boolean) is dead upon entry but overwritten

Avoid variables Parameter 's' is Avoid variables Parameter 's' is Avoid variables Parameter 's' is Avoid variables Parameter 's' is

with short names like s not assigned and could be declared final with short names like s not assigned and could be declared final with short names like s not assigned and could be declared final with short names like s not assigned and could be declared final

15 15 15 15 19 19 23 23 27 27 29 30 33 35 35 35 35 35 41 41 41 41 80 80 86 86 94 94 98 98

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs FindBugs FindBugs PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

clxxii

Software Defects Prevention Techniques Example Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

/** * Text form */

import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

//import java.io.*; //import java.util.*;

public class TextForm extends Form{ /** Name of waypoint */ TextField nameWP; /** Type of waypoint */ TextField typeWP; /** ChoiceGroup of categories */ ChoiceGroup chgr; TextField lat; TextField lon;

/** Creates new form */ TextForm(String[] s, boolean first){ super("Data Input"); nameWP = new TextField("Name","",50,0); typeWP = new TextField("Type","",50,0); this.append(nameWP); if(first = false){ //this.append(typeWP); this.append(""); chgr = new ChoiceGroup("Category",1,s,null); this.append(chgr); lat = new TextField("Latitude","",50,0); lon = new TextField("Longitude","",50,0); this.append(lat); this.append(lon); }else{
clxxiii

Zarko Acimovic

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

lat = new TextField("Latitude","",50,0); lon = new TextField("Longitude","",50,0); this.append(lat); this.append(lon); this.append(""); chgr = new ChoiceGroup("Category:",1,s,null); this.append(chgr); } } /** Returns the name of waypoint * @return String */ public String getName(){ return nameWP.getString(); } /** Returns the type of waypoint * @return String */ public String getType(){ return typeWP.getString(); } /** Sets the name of waypoint */ public void setName(String s){ nameWP.setString(s); } /** Sets the type of waypoint */ public void setType(String s){ typeWP.setString(s); } public int getSelected(){ return chgr.getSelectedIndex(); } public void setLat(long s){ lat.setString(MathFP.toString(s)); } public void setLon(long s){ lon.setString(MathFP.toString(s)); } public void setLat(String s){
clxxiv

Software Defects Prevention Techniques Example Project

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

lat.setString(s); } public void setLon(String s){ lon.setString(s); } public String getLat(){ return lat.getString(); } public String getLon(){ return lon.getString(); } }

TextFromFriend.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Pairwise Field Irrelation) is 83%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final

15 15 19 19 23 23 53 53 57 57 63 63

PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

clxxv

Zarko Acimovic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

/** * Text form */

import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

//import java.io.*; //import java.util.*;

public class TextFormFriend extends Form{ /** Name of waypoint */ TextField nameWP; /** Type of waypoint */ TextField typeWP;

/** Creates new form */ TextFormFriend(){ super("Data Input"); nameWP = new TextField("Name","",8,0); typeWP = new TextField("Type","",8,0); this.append(nameWP); this.append(typeWP); } /** Returns the name of waypoint * @return String */ public String getName(){ return nameWP.getString(); } /** Returns the type of waypoint * @return String */ public String getType(){ return typeWP.getString(); } /** Sets the name of waypoint
clxxvi

Software Defects Prevention Techniques Example Project

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

*/ public void setName(String s){ nameWP.setString(s); } public void setLabel(String s){ nameWP.setLabel(s); } /** Sets the type of waypoint */ public void setType(String s){ typeWP.setString(s); } }

TextFormImage.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 72% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 93% Lack of Cohesion in Methods (Total Correlation) is 88%
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like s Parameter 'img' is not assigned and could be declared final Parameter 'nameChg' is not assigned and could be declared final Parameter 's' is not assigned and could be declared final Read of unwritten field typeWP in TextFormImage.getType() Unwritten field: TextFormImage.typeWP Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Read of unwritten field typeWP in TextFormImage.setType(String) Avoid variables with short names like s Avoid variables with short names like s

15 15 15 15 19 19 27 27 34 34 39 39 39 39 59 59 64 64 70 70 71 78 82

PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs FindBugs PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker PMD Marker

clxxvii

Zarko Acimovic

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

/** * Text form for ChoicGroup with images */

import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

//import java.io.*; //import java.util.*;

public class TextFormImage extends Form{ /** Name of waypoint */ TextField nameWP; /** Category of waypoit */ // TextField catWP; /** Type of waypoint */ TextField typeWP; /** ChoiceGroup of categories */ // TextField lat; // TextField lon; ChoiceGroup chgr;

/** Creates new form */ TextFormImage(String nameChg, String[] s, Image[] img){ super("Data Input"); nameWP = new TextField("Name","",50,0); this.append(nameWP); this.append(""); chgr = new ChoiceGroup(nameChg,1,s,img); this.append(chgr); } /** Returns the name of waypoint * @return String */ public String getName(){
clxxviii

Software Defects Prevention Techniques Example Project

52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

return nameWP.getString(); } /** Returns the type of waypoint * @return String */ public String getType(){ return typeWP.getString(); } /** Sets the name of waypoint */ public void setName(String s){ nameWP.setString(s); } /** Sets the type of waypoint */ public void setType(String s){ typeWP.setString(s); } public int getSelected(){ return chgr.getSelectedIndex(); } public void setNameCHGR(String s){ chgr.setLabel(s); } public void setLat(long s){ //lat.setString(MathFP.toString(s)); } public void setLon(long s){ //lon.setString(MathFP.toString(s)); } }

clxxix

Zarko Acimovic

TextFormWP.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Chidamber & Kemerer) is 50 Lack of Cohesion in Methods (Henderson-Sellers) is 91% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 67% Lack of Cohesion in Methods (Total Correlation) is 351% Number of Fields is 11
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Lines of Code in Method is 39 Number of Statements is 23 Avoid variables with short names like s Parameter 's' is not assigned and could be declared final The user-supplied array 's' is stored directly. Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like r Local variable 'r' could be declared final Consider simply returning the value vs storing it in local variable 'r' Avoid variables with short names like r Local variable 'r' could be declared final Consider simply returning the value vs storing it in local variable 'r' Local variable 'r' could be declared final Consider simply returning the value vs storing it in local variable 'r' Local variable 's' could be declared final Local variable 'c' could be declared final Consider simply returning the value vs storing it in local variable 'k' Consider simply returning the value vs storing it in local variable 'r'

15 15 15 15 15 15 19 19 23 23 27 27 31 31 35 35 64 64 66 66 66 120 120 126 126 133 133 134 140 140 141 147 148 154 155 157 164

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

1 2 3 4 5 6 7 8 9 10 11 12 13 14

/** * Text form for insertion of waypoint */

import javax.microedition.lcdui.*; //import javax.microedition.midlet.*;

//import java.io.*; //import java.util.*;

clxxx

Software Defects Prevention Techniques Example Project

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

public class TextFormWP extends Form{ /** Name of waypoint */ TextField nameWP; /** Type of waypoint */ TextField typeWP; /** Degrees of latitude */ TextField degLat; /** Minutes of latitude */ TextField minLat; /** Seconds of latitude */ TextField secLat; /** Side NORTH / SOUTH */ TextField sideNS;

/** Degrees of longitude */ TextField degLon; /** Minutes of longitude */ TextField minLon; /** Seconds of longitude */ TextField secLon; /** Side WEST / EAST */ TextField sideWE; /** ChoiceGroup of categories */ ChoiceGroup chgr;

/** Creates new form */


clxxxi

Zarko Acimovic

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116

TextFormWP(String[] s){ super("Data Input"); nameWP = new TextField("Name","",12,0); this.append(nameWP); typeWP = new TextField("Type","",12,0); this.append(typeWP);

degLat = new TextField("Degrees of Latitude","",8,0); this.append(degLat); minLat = new TextField("Minutes of Latitude","",8,0); this.append(minLat); secLat = new TextField("Seconds of Latitude","",8,0); this.append(secLat); sideNS = new TextField("Side, North or South?","",8,0); this.append(sideNS);

degLon = new TextField("Degrees of Longitude","",8,0); this.append(degLon); minLon = new TextField("Minutes of Longitude","",8,0); this.append(minLon); secLon = new TextField("Seconds of Longitude","",8,0); this.append(secLon); sideWE = new TextField("Side, West or East?","",8,0); this.append(sideWE); chgr = new ChoiceGroup("Categories",1,s,null); this.append(chgr); } /** Returns the name of waypoint * @return String */ public String getName(){ return nameWP.getString(); } /** Returns the type of waypoint * @return String */ public String getType(){ return typeWP.getString(); }
clxxxii

Software Defects Prevention Techniques Example Project

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167

/** Sets the name of waypoint */ public void setName(String s){ nameWP.setString(s); } /** Sets the type of waypoint */ public void setType(String s){ typeWP.setString(s); } /** Returns degrees of latitude */ public int getDegLat(){ int r = Integer.parseInt(degLat.getString()); return r; } /** Returns minutes of latitude */ public int getMinLat(){ int r = Integer.parseInt(minLat.getString()); return r; } /** Returns seconds of latitude */ public int getSecLat(){ int r = Integer.parseInt(secLat.getString()); return r; } /** Returns side, North or South */ public char getSideNS(){ String s = sideNS.getString(); char[] c = s.toCharArray(); char k = c[0]; return k; } /** Returns degrees of longitude */ public int getDegLon(){ int r = Integer.parseInt(degLon.getString()); return r; } /** Returns minutes of longitude
clxxxiii

Zarko Acimovic

168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189

*/ public int getMinLon(){ int r = Integer.parseInt(minLon.getString()); return r; } /** Returns seconds of longitude */ public int getSecLon(){ int r = Integer.parseInt(secLon.getString()); return r; } /** Returns side, West or East */ public char getSideWE(){ String s = sideWE.getString(); char[] c = s.toCharArray(); char k = c[0]; return k; } }

clxxxiv

Software Defects Prevention Techniques Example Project

Thread4Friend.java
All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Chidamber & Kemerer) is 50 Lack of Cohesion in Methods (Henderson-Sellers) is 91% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 67% Lack of Cohesion in Methods (Total Correlation) is 351% Number of Fields is 11
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Lines of Code in Method is 39 Number of Statements is 23 Avoid variables with short names like s Parameter 's' is not assigned and could be declared final The user-supplied array 's' is stored directly. Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like s Parameter 's' is not assigned and could be declared final Avoid variables with short names like r Local variable 'r' could be declared final Consider simply returning the value vs storing it in local variable 'r' Avoid variables with short names like r All classes and interfaces must belong to a named package Lack of Cohesion in Methods (Henderson-Sellers) is 91% Lack of Cohesion in Methods (Pairwise Field Irrelation) is 54% Lack of Cohesion in Methods (Total Correlation) is 420% The class 'Thread4Friend' has a Cyclomatic Complexity of 4 (Highest = 10). To be compliant to J2EE, a webapp should not use any thread. Avoid variables with short names like t
Found non-transient, non-static member. Please mark as transient or provide accessors.

To be compliant to J2EE, a webapp should not use any thread. Use explicit scoping instead of the default package private level Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Consider replacing this Vector with the newer java.util.List
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level


Found non-transient, non-static member. Please mark as transient or provide accessors.

15 15 15 15 15 15 19 19 23 23 27 27 31 31 35 35 64 64 66 66 66 120 120 126 126 133 133 134 140 13 13 13 13 13 13 14 14 14 14 15 15 15 15 15 16 16 17

PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker

clxxxv

Zarko Acimovic

Thread4Friend.java
Use explicit scoping instead of the default package private level Avoid variables with short names like ic
Found non-transient, non-static member. Please mark as transient or provide accessors.

Use explicit scoping instead of the default package private level Avoid variables with short names like mb Avoid using implementation types like 'Vector'; use the interface instead Avoid using implementation types like 'Vector'; use the interface instead Avoid variables with short names like ic Avoid variables with short names like mb Consider replacing this Vector with the newer java.util.List Number of Parameters is 6 Parameter 'ic' is not assigned and could be declared final Parameter 'mb' is not assigned and could be declared final Parameter 'mob' is not assigned and could be declared final Parameter 'oul' is not assigned and could be declared final Parameter 'resource' is not assigned and could be declared final Unread field: Thread4Friend.oul To be compliant to J2EE, a webapp should not use any thread. Cyclomatic Complexity is 8 Lines of Code in Method is 66 Number of Levels is 5 Number of Locals in Scope is 17 Number of Statements is 75 The method 'run' has a Cyclomatic Complexity of 10. To be compliant to J2EE, a webapp should not use any thread. Avoid instantiating new objects inside loops Local variable 's' could be declared final Local variable 'lastIndex' could be declared final Avoid unused local variables such as 'currentTS'. The local variable currentTS is never read Avoid instantiating new objects inside loops Position literals first in String comparisons Local variable 'comma' could be declared final Local variable 'nextComma' could be declared final Assigning an Object to null is a code smell. Consider refactoring. Position literals first in String comparisons Avoid instantiating new objects inside loops Avoid empty catch blocks Thread4Friend.run() might ignore java.lang.Exception Avoid unnecessary comparisons in boolean expressions Lines of Code in Method is 19 Avoid unused local variables such as 'k'. Dead store to k in Thread4Friend.compact(String) Local variable 'k' could be declared final The local variable k is never read Avoid using if statements without curly braces Prefer StringBuffer over += for concatenating strings

17 18 18 18 19 24 24 24 24 24 24 24 24 24 24 24 25 31 45 45 45 45 45 45 47 52 53 59 67 67 71 75 79 81 90 91 92 98 98 102 114 120 120 120 120 126 126

PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker Metrics Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker Java Problem PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker PMD Marker FindBugs PMD Marker Metrics Marker PMD Marker FindBugs PMD Marker Java Problem PMD Marker PMD Marker

clxxxvi

Software Defects Prevention Techniques Example Project

Thread4Friend.java
Thread4Friend.compact(String) concatenates strings using + in a loop Avoid unused local variables such as 'kk'. Dead store to kk in Thread4Friend.compact(String) The local variable kk is never read Avoid unused local variables such as 'k'. Dead store to k in Thread4Friend.compactFine(String) The local variable k is never read Avoid using if statements without curly braces Prefer StringBuffer over += for concatenating strings Thread4Friend.compactFine(String) concatenates strings using + in a loop Avoid unused local variables such as 'kk'. Dead store to kk in Thread4Friend.compactFine(String) The local variable kk is never read Cyclomatic Complexity is 6 Lines of Code in Method is 31 Number of Statements is 24 Avoid empty catch blocks Avoid empty catch blocks Prefer StringBuffer over += for concatenating strings
Thread4Friend.getResourceAsString(String) concatenates strings using + in a loop

126 129 129 129 135 135 135 141 141 141 144 144 144 149 149 149

FindBugs PMD Marker FindBugs Java Problem PMD Marker FindBugs Java Problem PMD Marker PMD Marker FindBugs PMD Marker FindBugs Java Problem Metrics Marker Metrics Marker Metrics Marker

153 PMD Marker 164 PMD Marker 167 PMD Marker 167 FindBugs 170 PMD Marker 173 FindBugs 174 PMD Marker

Avoid empty catch blocks


Possible null pointer dereference of is in Thread4Friend.getResourceAsString(String) on exception path

Avoid empty catch blocks

clxxxvii

Zarko Acimovic

1 /** 2 * 3 * Thread4Friend controls apperance of friend's position on screen 4 */ 5 //import javax.microedition.lcdui.*; 6 7 //import javax.microedition.midlet.*; 8 9 import java.util.*; 10 import java.io.*; 11 12 13 public class Thread4Friend implements Runnable{ 14 Thread t; 15 Vector whiteList; 16 String resource; 17 MapObjects mob; 18 ImageCanvas3 ic; 19 MapBackground mb; 20 Outlook oul; 21 int hashID; 22 boolean first = false; 23 24 Thread4Friend(Vector whiteList, String resource, MapObjects mob, ImageCanvas3 ic, MapBackground mb, Outlook oul){ 25 this.oul = oul; 26 this.mob = mob; 27 this.mb = mb; 28 this.ic = ic; 29 this.resource = resource; 30 this.whiteList = whiteList; 31 t = new Thread(this); 32 //t.start(); 33 hashID = t.hashCode(); 34 } 35 36 public void start(){ 37 38 t.start(); 39 } 40 41 public int getID(){ 42 return hashID; 43 } 44 45 public void run(){ 46 47 Thread current = Thread.currentThread(); 48 //System.out.println*
clxxxviii

Software Defects Prevention Techniques Example Project

49 Integer friendID = new Integer(current.hashCode()); 50 while(whiteList.contains(friendID)){ 51 current = Thread.currentThread(); 52 friendID = new Integer(current.hashCode()); 53 String s = this.getResourceAsString(resource); 54 int nextIndex = 6; 55 int index = s.indexOf('\n'); 56 57 nextIndex = s.indexOf('\n',index+1); 58 59 int lastIndex = s.lastIndexOf('\n'); 60 61 int begin = -2; 62 int end = index; 63 64 String c1 = ""; 65 String c2 = ""; 66 String timeStamp = ""; 67 long currentTS = 0; 68 69 while(index<lastIndex && whiteList.contains(friendID)){ 70 current = Thread.currentThread(); 71 friendID = new Integer(current.hashCode()); 72 Point wp = null; 73 String temp = s.substring(begin+2,end); 74 temp = compact(temp); 75 if(temp.equals("")){ //na kraju ce temp da bude prazno 76 index = lastIndex+1; 77 } else { 78 temp = compact(temp); 79 int comma = temp.indexOf(','); 80 c1 = temp.substring(0,comma); 81 int nextComma = temp.indexOf(',',comma+1); 82 c2 = temp.substring(comma+1,nextComma); 83 timeStamp = temp.substring(nextComma+1,temp.length()); 84 currentTS = Long.parseLong(timeStamp); 85 begin = index-1; 86 end = nextIndex; 87 index = nextIndex; 88 nextIndex = s.indexOf('\n',nextIndex+1); 89 90 wp = null; 91 if(!c1.equals("")){

clxxxix

Zarko Acimovic

92 wp = new Point(c2,c1,resource,"","",true); 93 wp.setImage("blanco"); 94 } 95 } 96 try{ 97 Thread.sleep(1000); 98 }catch(Exception e){} 99 if(wp!=null && whiteList.contains(friendID)){ 100 mob.setDrawablePoints(); 101 mob.updateFriend(friendID,wp); 102 if(first==false) { 103 mb.setBackground(wp); 104 first=true; 105 } 106 ic.repaint(); 107 } 108 } 109 } 110 } 111 112 113 114 /** Blanco characters are possible to occur in names of pictures; 115 * Integer representations of blanko characters are 9 and 32 116 * Also, characters with integer representation between 0 and 33 117 * can not be printed out in WSDD console, so I excluded them too 118 */ 119 public String compact(String s){ 120 int k = s.length(); 121 //System.out.println("Length of s is "+s.length()); 122 char[] d = s.toCharArray(); 123 String ret = ""; 124 for(int i=0; i<d.length; i++){ 125 int temp = (int)d[i]; 126 if(temp>32) ret+=d[i]; 127 } 128 //System.out.println("Length of ret is "+ret.length()); 129 int kk = ret.length(); 130 //if (kk!=k) System.out.println("Bugger is: "+s); 131 return ret; 132 } 133 134 public String compactFine(String s){ 135 int k = s.length(); 136 //System.out.println("Length of s is "+s.length()); 137 char[] d = s.toCharArray(); 138 String ret = ""; 139 for(int i=0; i<d.length; i++){ 140 int temp = (int)d[i];
cxc

Software Defects Prevention Techniques Example Project

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

if(temp!=32 && temp!=9) ret+=d[i]; } //System.out.println("Length of ret is "+ret.length()); int kk = ret.length(); //if (kk!=k) System.out.println("Bugger is: "+s); return ret; } public String getResourceAsString(String resource){ InputStream is = null; try{ is = this.getClass().getResourceAsStream(resource); }catch(Exception e) { //a.setString("There is no such resource"); //d.setCurrent(a); } //conversion of resource into string String s = ""; char m =' '; try{ m = (char)is.read(); }catch(Exception e){} while(m!=65535){ s+=m; try{ m = (char)is.read(); }catch(Exception e){} } try{ is.close(); }catch(Exception e){}

s=compactFine(s); return s; } public void setFirst(){ first = false; } }

cxci

Zarko Acimovic

6 DESIGN DEFECTS DETECTED BY ARGOUML

15.3. Class Selection 15.3.1. Wrap DataType 15.3.2. Reduce Classes in namespace <namespace> 15.3.3. Clean Up Diagram 15.4. Naming 15.4.1. Resolve Association Name Conflict 15.4.2. Revise Attribute Names to Avoid Conflict 15.4.3. Change Names or Signatures in a model element 15.4.4. Duplicate End (Role) Names for an Association 15.4.5. Role name conflicts with member 15.4.6. Choose a Name (Classes and Interfaces) 15.4.7. Name conflict in a namespace 15.4.8. Choose a Unique Name for a model element (Classes and Interfaces) 15.4.9. Choose a Name (Attributes) 15.4.10. Choose a Name (Operations) 15.4.11. Choose a Name (States) 15.4.12. Choose a Unique Name for a (State related) model element 15.4.13. Revise Name to Avoid Confusion 15.4.14. Choose a Legal Name 15.4.15. Change a model element to a Non-Reserved Word 15.4.16. Choose a Better Operation Name 15.4.17. Choose a Better Attribute Name 15.4.18. Capitalize Class Name
cxcii

Software Defects Prevention Techniques Example Project

15.4.19. Revise Package Name 15.5. Storage 15.5.1. Revise Attribute Names to Avoid Conflict 15.5.2. Add Instance Variables to a Class 15.5.3. Add a Constructor to a Class 15.5.4. Reduce Attributes on a Class 15.6. Planned Extensions 15.6.1. Operations in Interfaces must be public 15.6.2. Interfaces may only have operations 15.6.3. Remove Reference to Specific Subclass 15.7. State Machines 15.7.1. Reduce Transitions on <state> 15.7.2. Reduce States in machine <machine> 15.7.3. Add Transitions to <state> 15.7.4. Add Incoming Transitions to <model element> 15.7.5. Add Outgoing Transitions from <model element> 15.7.6. Remove Extra Initial States 15.7.7. Place an Initial State 15.7.8. Add Trigger or Guard to Transition 15.7.9. Change Join Transitions 15.7.10. Change Fork Transitions 15.7.11. Add Choice/Junction Transitions 15.7.12. Add Guard to Transition 15.7.13. Clean Up Diagram 15.7.14. Make Edge More Visible 15.7.15. Composite Association End with Multiplicity >1 15.8. Design Patterns

cxciii

Zarko Acimovic

15.8.1. Consider using Singleton Pattern for <class> 15.8.2. Singleton Stereotype Violated in <class> 15.8.3. Nodes normally have no enclosers 15.8.4. NodeInstances normally have no enclosers 15.8.5. Components normally are inside nodes 15.8.6. ComponentInstances normally are inside nodes 15.8.7. Classes normally are inside components 15.8.8. Interfaces normally are inside components 15.8.9. Objects normally are inside components 15.8.10. LinkEnds have not the same locations 15.8.11. Set classifier (Deployment Diagram) 15.8.12. Missing return-actions 15.8.13. Missing call(send)-action 15.8.14. No Stimuli on these links 15.8.15. Set Classifier (Sequence Diagram) 15.8.16. Wrong position of these stimuli 15.9. Relationships 15.9.1. Circular Association 15.9.2. Make <association> Navigable 15.9.3. Remove Navigation from Interface via <association> 15.9.4. Add Associations to <model element> 15.9.5. Remove Reference to Specific Subclass 15.9.6. Reduce Associations on <model element> 15.9.7. Make Edge More Visible 15.10. Instantiation 15.11. Modularity 15.11.1. Classifier not in Namespace of its Association 15.11.2. Add Elements to Package <package>
cxciv

Software Defects Prevention Techniques Example Project

15.12. Expected Usage 15.12.1. Clean Up Diagram 15.13. Methods 15.13.1. Change Names or Signatures in <model element> 15.13.2. Class Must be Abstract 15.13.3. Add Operations to <class> 15.13.4. Reduce Operations on <model element> 15.14. Code Generation 15.14.1. Change Multiple Inheritance to interfaces 15.15. Stereotypes 15.16. Inheritance 15.16.1. Revise Attribute Names to Avoid Conflict 15.16.2. Remove <class>'s Circular Inheritance 15.16.3. Class Must be Abstract 15.16.4. Remove final keyword or remove subclasses 15.16.5. Illegal Generalization 15.16.6. Remove Unneeded Realizes from <class> 15.16.7. Define Concrete (Sub)Class 15.16.8. Define Class to Implement <interface> 15.16.9. Change Multiple Inheritance to interfaces 15.16.10. Make Edge More Visible 15.17. Containment 15.17.1. Remove Circular Composition 15.17.2. Duplicate Parameter Name 15.17.3. Two Aggregate Ends (Roles) in Binary Association 15.17.4. Aggregate End (Role) in 3-way (or More) Association 15.17.5. Wrap DataType

cxcv

Zarko Acimovic

9 EXAMPLES OF DESIGN DEFECTS IN ARGOUML

cxcvi

Software Defects Prevention Techniques Example Project

cxcvii

Zarko Acimovic

cxcviii

Software Defects Prevention Techniques Example Project

ABOUT THE AUTHOR


Zarko Acimovic was born in 1977 in Belgrade, SERBIA. He obtained his BSc in Computer Science at University of Belgrade, School of Electrical Engineering. Zarko Acimovic maintains Facebook page for promoting automated testing of software architecture and software design http://www.facebook.com/AutomatedTesting

cxcix

Follow me on Facebook page Automated Testing https://www.facebook.com/AutomatedTesting

Search for people, places and things

Automated Testing Edit Page Build Audience Help Show

Home

Admin Panel

Ads Manager

See Your Ad Here Automated Testing

Automated Testing as Program Verification. Program Verification problem is decidable if P is finite-... Like Automated Testing likes this. Get More Likes

Automated Testing
10 likes 1 talking about this Computers/Internet Website Automated Testing as Program Verification. Program Verification problem is decidable if P is finite-state with model-checking techniques. But real programs are not finite-state, they have arbitrarily complex inputs and dynamic memory allocation About Photos Likes

Now February 2013 Launched

10

Highlights

Status

Photo / Video

Event, Milestone +

Recent Posts by Others on Automated Testing Zarko Acimovic http://www.verifysoft.com/en.html Wednesday at 2:24pm Zarko Acimovic http://hermit-reasoner.com/ February 15 at 11:26am More Posts

See All

What's on your mind?

Automated Testing shared a link. 9 minutes ago

http://www-dse.doc.ic.ac.uk/cgi-bin/moin.cgi/sue
sue - DSE Imperial College www-dse.doc.ic.ac.uk Distributed Software Engineering Section Department of Computing Imperial College London Huxley Building Room 568 180 Queen's Gate, London SW7 2AZ, UKDirections to the DepartmentStreetmap link Phone: +44 20 7594 8264 Fax: +44 20 7581 8024

Likes Erlang Programming Community Alonso Church Public Figure Objective Caml Interest Implementing Automated Software Testing Book Haskell Interest

See All

Like Comment Share

Automated Testing shared a link. 40 minutes ago

http://sourceforge.net/projects/czt/
Community Z Tools sourceforge.net Tool support for the Z formal notation

Like Comment Share

Automated Testing shared a link. about an hour ago

Automated Testing shared a link. about an hour ago

http://www.doc.ic.ac.uk/~ar3/lectures/ProgrammingII/NewCours eStructure.html
Alessandra Russo's Software Engineering Course www.doc.ic.ac.uk These lecture notes are designed for the second part of the course Object Oriented Programming given to first year undergraduate students at Imperial College. The first half of this course is taught by Alastair

http://www.doc.ic.ac.uk/~jnm/book/index.html

Donaldson. His lecture notes are electronically available on CATE. The second part of thi... Like Comment Share

Like Comment Share Concurrency - State Models & Java Programs www.doc.ic.ac.uk

Automated Testing shared a link. 16 hours ago

http://www.cs.ru.nl/ftfjp/
Formal Techniques for Java-like Programs (FTfJP) www.cs.ru.nl Starting 2002 the name of the workshop has been slightly changed from "Formal Techniques for Java Programs" to "Formal Techniques for Java-like Programs" - to include not just work on Java, but also work on related languages such as C# or Scala.

Automated Testing 16 hours ago

http://www.cs.ru.nl/ftfjp/
Like Comment Share

Like Comment Share Automated Testing shared a link. 16 hours ago

http://www.uppaal.com/index.php?sida=186&rubrik=93
UP4ALL Inc - uppaal.com www.uppaal.com UPPAAL is an integrated tool environment for modeling, simulation and, verification of real-time embedded systems. Typical application areas of UPPAAL includes real-time controllers and communication protocols in particular, those where timing aspects are critical.

Automated Testing 16 hours ago

http://csd.informatik.uni-oldenburg.de/~moby/
Like Comment Share

Like Comment Share

Automated Testing shared a link. Thursday

Automated Testing shared a link. Wednesday

http://www.informatik.unibremen.de/agbkb/forschung/formal_methods/index_e.htm
Research Area "Formal Methods for Software Development" www.informatik.uni-bremen.de The main focus of research in formal methods at our group is algebraic specification, based on the CASL language, and development of effective tool support for all aspects of formal development.

http://www.springer.com/computer/swe/book/978-0-85729-2766
Specification of Software Systems www.springer.com Recent advances in software specification methods, model checking, and theorem proving have generated new tools for the use of formal methods in both industry and academia. Yet, in order to choose the techniques most appropriate ... Like Comment Share

Like Comment Share

Automated Testing shared a link. March 5

http://www.locmetrics.com/index.html
Automated Testing shared a link. March 5 http://www.locmetrics.com/index.html www.locmetrics.com

http://www.locmetrics.com/alternatives.html
LOC Metrics - Alternative Tools www.locmetrics.com LocMetrics is a simple tool for counting lines of code in C#, Java, and C++.

Like Comment Share

Automated Testing shared a link. March 1

Like Comment Share

http://www.flowgate.net/?lang=es&seccion=herramientas
[Flowgate Consulting] Servicios de consultoria en TI www.flowgate.net

Automated Testing shared a link. February 28

http://www.lispworks.com/
LispWorks www.lispworks.com New features in LispWorks 6.1 include environment access, high-quality drawing including anti-aliasing, exporting various image formats, extensions to symmetric multiprocessing and a 64-bit FreeBSD port. Like Comment Share Like Comment Share

Automated Testing shared a link. February 28

http://weitz.de/

Automated Testing shared a link. February 28

Edi Weitz weitz.de Software, books, photos, and more

http://www.cliki.net/
CLiki: index www.cliki.net CLiki is a Common Lisp wiki. It contains resources for learning about and using the programming language Common Lisp, and information about DFSG-compliant free software implemented in Common Lisp.

Like Comment Share

Automated Testing shared a link. February 28

http://cs.gmu.edu/~sean/book/metaheuristics/
Like Comment Share Essentials of Metaheuristics cs.gmu.edu Automated Testing shared a link. February 28 Please always include the URLit's the only unique identifier to the text! Note the lack of edition number: I expect these to change very rapidly, and Google Scholar and Citeseer both have trouble with fastchanging editions. If you prefer BibTeX: @Book{ Luke2009Metaheuristics, author = { Sean Luke ... Like Comment Share

http://www.franz.com/
About Franz Inc. www.franz.com Franz is a leading vendor of Semantic Web Technology featuring the AllegroGraph RDF Store triple store database, and dynamic object-oriented Common Lisp development tools including Allegro Common Lisp with AllegroCache, an Object Database that provides Object Persistence in Lisp, native to the langa... Like Comment Share

Automated Testing shared a link. February 28

http://cs.gmu.edu/~sean/lisp/
Lisp at GMU cs.gmu.edu

Automated Testing shared a link. February 28

http://letoverlambda.com/index.cl
Let Over Lambda letoverlambda.com Let Over Lambda (ISBN 978-1-4357-1275-1, 376+iv pp.) is one of the most hardcore computer programming books out there. Starting with the fundamentals, it describes the most advanced features of the most advanced language: COMMON LISP. The point of this book is to expose you to ideas that you might o... Like Comment Share

Lisp runs fine on mason.gmu.edu (type lisp). But only use Lisp on Mason to verify your code, not for development. Instead, do development on your own machine -- it's much less painful. However, in Prof. Luke's classes, your Lisp homework and projects must compile and run properly on Mason for them t... Like Comment Share

Automated Testing shared a link. February 27

http://cs.brown.edu/~jes/book/
Models of Computation: Exploring the Power of Computing cs.brown.edu

Automated Testing shared a link. February 27

http://cs.brown.edu/~jes/book/pdfs/ModelsOfComputation_Chapt er4.pdf
http://cs.brown.edu/~jes/book/pdfs/ModelsOfComputation_C hapter4.pdf cs.brown.edu

In Models of Computation:Exploring the Power of Computing, John Savage re-examines theoretical computer science, offering a fresh approach that gives priority to resource tradeoffs and complexity classifications over the structure of machines and their relationships to languages. This viewpoint refl... Like Comment Share

Automated Testing shared a link. February 27

Like Comment Share

Automated Testing shared a link. February 27

http://www.google.rs/search? q=%22%22&oq=%22%22&sourceid=chrome&client=ubuntu&ch annel=cs&ie=UTF8#client=ubuntu&hs=OiJ&channel=cs&sclient=psyab&q=Program+verification+is+decidable+if+P+is+finitestae&oq=Program+verification+is+decidable+if+...See More


"" - Google www.google.rs

http://research.microsoft.com/en-us/projects/chess/
CHESS - Microsoft Research research.microsoft.com A concurrency testing tool for finding and reproducing Heisenbugs. CHESS repeatedly runs a concurrent test ensuring that every run takes a different interleaving. If an interleaving results in an error, CHESS can reproduce the interleaving for improved debugging. Like Comment Share Automated Testing February 27

Like Comment Share

http://research.microsoft.com/en-us/projects/chess/
Automated Testing shared a link. February 25 Like Comment Share

http://www.cambridge.org/gb/knowledge/isbn/item1112106/? site_locale=en_GB
Logic in Computer Science www.cambridge.org Recent years have seen the development of powerful tools for verifying hardware and software systems, as companies worldwide realise the need for improved means of validating their products. There is increasing demand for training in basic methods in formal reasoning so that students can gain profic... Like Comment Share

Earlier in February

Zarko Acimovic shared a link. February 15

Automated Testing February 14

http://hermit-reasoner.com/
HermiT Reasoner: Home hermit-reasoner.com HermiT is reasoner for ontologies written using the Web Ontology Language (OWL). Given an OWL file, HermiT can determine whether or not the ontology is consistent, identify subsumption relationships between classes, and much more.

John Hughes. Why functional programming matters - Google search


Like Comment Share

Automated Testing shared a link. February 14

Like Comment Share

http://www.amazon.com/Purely-Functional-Structures-ChrisOkasaki/dp/0521663504
Purely Functional Data Structures www.amazon.com Most books on data structures assume an imperative language such as C or C++. However, data structures for these languages do not always translate well to functional languages such as Standard ML, Haskell, or Scheme. This book describes data structures from the point of view of functional languag... Like Comment Share

Automated Testing shared a link. February 14

http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf "Purely Functional Data Structures"


http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf www.cs.cmu.edu

Like Comment Share

Automated Testing shared a link. February 14

Automated Testing shared a link. February 14

http://okasaki.blogspot.com/
Teaching, Playing, and Programming okasaki.blogspot.com I think youll enjoy this game, Thunderstone. Ive been playing it a lot with my son. Like Race for the Galaxy, this one works very well with two players, but can also handle more players. (Predictably, with more players, it becomes very chaotic, especially when thieves are in play) Im so certain Like Comment Share

http://www.sonarsource.com/
SonarSource - Continuous Inspection of Code Quality www.sonarsource.com SonarSource provides applications and services for continuous inspection of code quality. Its open source Sonar platform and commercial products help customers to perform development and long-term maintenance of software at a lower cost and with reduced risk.

Like Comment Share

Automated Testing shared a link. February 12

Automated Testing shared a link. February 11

scg.unibe.ch/archive/famoos/handbook/4handbook.pdf The FAMOOS Object-Oriented Reengineering Handbook


http://scg.unibe.ch/archive/famoos/handbook/4handbook.pdf scg.unibe.ch

http://xray.inf.usi.ch/xray.php Software is inherently intangible. Systems can be composed of a huge amount of software entities linked together by different

kinds of dependencies. Software designers use visualization tools in order to rai...See More
Jacopo Malnati, X-Ray 1.0.4.1 xray.inf.usi.ch Website of Jacopo Malnati

Like Comment Share

Automated Testing shared a link. February 11

Like Comment Share

http://jhave.org/ JHAV is a java application that renders algorithm visualizations. Students explore algorithms by viewing visual representations of data, controlling movement and by responding to pop-up questions. We provide a large colle...See More
JHAVE: Home Page jhave.org JHAVE

Automated Testing shared a link. February 10

http://www.arisa.se/index.php Goal of ARiSA - Applied Research in System Analysis - is to leverage quality management on software and information systems engineering. We provide seminars, methods, and development tools supporting the effi...See More
ARiSA AB www.arisa.se Mlet fr ARiSA r att utnyttja kvalitetshantering av framtagning mjukvaru- och informationssystem. Vi tillhandahller seminarier, metoder och utvecklingsverktyg som stdjer effektiv produktion och underhll av hgkvalitativ mjukvara.

Like Comment Share

Automated Testing shared a link. February 10

http://www.arisa.se/compendium/quality-metricscompendium.html
Compendium of Software Quality Standards and Metrics Version 1.0 www.arisa.se Compendium of Software Quality Standards and Metrics - Version 1.0

Like Comment Share

Automated Testing shared a link. February 4

Like Comment Share

http://research.microsoft.com/en-us/projects/specsharp/
Spec# - Microsoft Research research.microsoft.com Spec# is a formal language for API contracts (influenced by AsmL, JML and Eiffel), which extends C# with constructs for non-null types, preconditions, postconditions, object invariants, and model programs (behavioral contracts that take the history of the entire run into account). Spec# comes with a... Like Comment Share

Automated Testing shared a link. February 4

http://types.cs.washington.edu/jsr308/
Type Annotations (JSR 308) and the Checker Framework types.cs.washington.edu The Java 6 annotation syntax is useful but limited. The Type Annotations syntax permits annotations to be written in more places, such as generic type arguments: List<@NonNull Object>. Programmers can use type annotations to write more informative types, and then tools such as type-checkers can det Like Comment Share

Automated Testing shared a link. February 4

http://groups.csail.mit.edu/pag/daikon/
The Daikon dynamic invariant detector groups.csail.mit.edu Daikon is an implementation of dynamic detection of likely invariants; that is, the Daikon invariant detector reports likely program invariants. An invariant is a property that holds at a certain point or points in a program; these are often seen in assert statements, documentation, and formal speci... Like Comment Share

Automated Testing shared a link. February 4

http://homes.cs.washington.edu/~mernst/software/
Software released by Michael Ernst homes.cs.washington.edu This is a partial list of software packages released by Michael Ernst. I am always happy to receive comments, bug reports and fixes, and improvements to the code. I will attempt to assist you with problems or incorporate your changes into the main source. Unless otherwise noted, all software should Like Comment Share

Automated Testing shared a link. February 3

http://se.inf.ethz.ch/courses/2012b_fall/sv/
Software Verification - Fall 2012 - Chair of Software Engineering se.inf.ethz.ch 05.12.2012 Please remember to bring questions/problems along for the exercise session of next week! The exam is approaching fast now...

Automated Testing shared a link. February 3

http://ix.cs.uoregon.edu/~michal/

Like Comment Share

Automated Testing shared a link. February 3

Like Comment Share

The Program Verification problem is decidable if P is finite-state with model-checking techniques. But real programs are not finite-state arbitrarily complex inputs dynamic memory allocation The term Software Model-Checking denotes techniques to automatically verify real programs based on finite-state models of them.
Index of /courses/2012b_fall/sv/slides se.inf.ethz.ch

Michal Young ix.cs.uoregon.edu The thread that runs through my work is understanding how we understand and gain confidence in software, through some combination Automated Testing shared a link. of analysis (broadly construed to include testing as well as various static February 2 checking techniques) and design. I'm increasingly interested in interplay between synthesis (g...

http://www.scribd.com/doc/65043293/Introduction-to-ComputerTheory
http://www.scribd.com/doc/65043293/Introduction-toComputer-Theory www.scribd.com

Like Comment Share

Like Comment Share

Automated Testing shared a link. February 1

Automated Testing shared a link. February 1

http://www.ncl.ac.uk/computing/research/?pid=260
Research home - Computing Science - Newcastle University www.ncl.ac.uk We carry out fundamental computing science research which we evaluate and extend through application to industrial and interdisciplinary challenges. Our work constantly evolves to address the new challenges posed by a fast-changing environment: one in which computer systems become ever more complex,... Like Comment Share

http://www.wou.edu/~broegb/
Index Winter 2013 www.wou.edu

Like Comment Share

Automated Testing shared a link. February 1

Automated Testing shared a link. February 1

http://rodin.cs.ncl.ac.uk/
RODIN - Rigorous Open Development Environment for Complex Systems rodin.cs.ncl.ac.uk Our overall objective is the creation of a methodology and supporting open tool platform for the cost effective rigorous development of dependable complex software systems and services. We focus on tackling complexity caused by the environment in which t...

http://www.ai4fm.org/
Overview - AI4FM www.ai4fm.org AI4FM project aims to use "learning" techniques from artificial intelligence to record and abstract how experts do proofs in order to increase the proportion of cases where proofs are constructed without (or with minimal) human intervention. AI4FM is an EPSRCfunded research project, a joint effort

Like Comment Share

Like Comment Share

Automated Testing shared a link. February 1

http://homepages.cs.ncl.ac.uk/cliff.jones/
http://homepages.cs.ncl.ac.uk/cliff.jones/ homepages.cs.ncl.ac.uk Much of his research at this time focused on formal (compositional) development methods for concurrent systems. His major avenues of current research are listed below.

Like Comment Share

Earlier in 2013

Automated Testing shared a link. January 31

Likes
2013

https://www.scss.tcd.ie/Matthew.Hennessy/teaching/2013/slexter nal2013/reading.php
Semantics of programming languages - 2012/13 Reading list - Computer Science - Trinity College Dubl www.scss.tcd.ie Trinity College Dublin: Computer Science Department: Semantics of programming languages - 2012/13 Reading list Like Comment Share

+3
Alonso Church Objective Caml F Sharp

Automated Testing shared a link. January 30

http://elib.mi.sanu.ac.rs/files/journals/mv/202/mv943409.pdf
http://elib.mi.sanu.ac.rs/files/journals/mv/202/mv943409.pdf elib.mi.sanu.ac.rs

Automated Testing January 29

http://se.inf.ethz.ch/old/projects/tobias_widmer/
Like Comment Share

Like Comment Share

Automated Testing shared a link. January 28 Automated Testing shared a link. January 28

http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-737.pdf
http://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-737.pdf www.cl.cam.ac.uk

http://bertrandmeyer.com/2012/04/11/domain-theory-theforgotten-step-in-program-verification/
Bertrand Meyer's technology+ blog Blog Archive Domain Theory: the forgotten step in program v bertrandmeyer.com Program verification is making considerable progress but is hampered by a lack of abstraction in specifications. A crucial step is, almost always, absent from the process; this omission is the principal obstacle to making verification a standard component of everyday software development.

Like Comment Share

Automated Testing shared a link. January 28

Like Comment Share

http://ebooks.cambridge.org/chapter.jsf? bid=CBO9780511569883&cid=CBO9780511569883A012
Cambridge Books Online - The Statement of the Incompleteness Theorem ebooks.cambridge.org The automatic verification of large parts of mathematics has been an aim of many mathematicians from Leibniz to Hilbert. While Gdel's first incompleteness theorem showed that no computer program could automatically prove certain true Like Comment Share theorems in mathematics, the advent of electronic computers and s...

Automated Testing shared a link. January 28

http://www.amzi.com/
Amzi! inc. Embeddable Extendable Prolog, Logic Server, Knowledge Engineering, Rule Engines, Artifici www.amzi.com Amzi! inc. provides software and services for embedding intelligent components that apply busines rules, diagnose problems, recommend configurations, give advice, schedule events, monitor processes and more. Like Comment Share

Automated Testing shared a link. January 28

http://www.computational-semantics.eu/
Automated Testing shared a link. January 28 Computational Semantics with Functional Programming www.computational-semantics.eu ESSLLI Summer School Course, Ljubljana, Slovenia, August 2011. See the course description on the ESSLLI 2011 homepage.

http://homepages.cwi.nl/~jve/problem5/
Challenging Imperative Programming with Algebra, Logic and Functions homepages.cwi.nl ``How much land does a man need?'' asked Lev Tolstoi, and the answer turned out to be: surprisingly little. ``How many programming languages does a software designer need?'' The answer seems to be: surprisingly many. See below. Like Comment Share

Like Comment Share

Automated Testing shared a link. January 28

http://answers.yahoo.com/question/index?qid=1006030700479
Automated Testing shared a link. January 28

http://en.wikipedia.org/wiki/Lambda_calculus

Lambda calculus - Wikipedia, the free encyclopedia en.wikipedia.org Lambda calculus (also written as -calculus or called "the lambda calculus") is a formal system in mathematical logic and computer science for expressing computation by way of variable binding and substitution. First formulated by Alonzo Church, lambda calculus found early successes Like Comment in the area of c... Share

Like Comment Share

What is the difference between logic programming and imperative programming.? answers.yahoo.com Logic programming Testing shared a link. Automated (sometimes called logical programming) is programming that makes use of pattern-directed invocation of January 28 procedures from assertions and goals. John McCarthy [1958] was the first to pub

Automated Testing shared a link. January 28

http://racket-lang.org/ http://users.soe.ucsc.edu/~cormac/
Cormac Flanagan Homepage users.soe.ucsc.edu

The Racket Language racket-lang.org Racket is a modern programming language in the Lisp/Scheme family, suitable for a wide range of applications. Racket provides a rich language extension API, the DrRacket integrated development environment, and many batteries-included libraries.

Like Comment Share Like Comment Share

Automated Testing shared a link. January 28

Automated Testing shared a link. January 28

http://link.springer.com/book/10.1007/978-1-84628-692-6/page/1 http://classes.soe.ucsc.edu/cmps112/Winter07/
CMPS 112 - Comparative Programming Languages - Winter 2007 classes.soe.ucsc.edu Lectures: Tu/Th, 10:00-11:45am, Engineering 2, room 194Lab Sessions: Mondays 1:00-3:00pm and Thursdays 5:00-6:00pm, both in Baskin 105 Semantics with Applications: An Appetizer Springer link.springer.com

Like Comment Share

Like Comment Share

Automated Testing shared a link. January 28

Automated Testing shared a link. January 28

http://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-0426/
Programming Languages: Application and Interpretation by Shriram Krishnamurthi cs.brown.edu Programming Languages: Application and Interpretation Copyright 2003-07, Shriram Krishnamurthi Creative Commons AttributionNonCommercial-ShareAlike 3.0 United States License Version 2007-04-26 Like Comment Share

http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html
Teach Yourself Scheme in Fixnum Days www.ccs.neu.edu A practical introduction to the programming language Scheme

Like Comment Share

Automated Testing shared a link. January 26

Automated Testing shared a link. January 26

http://mitpress.mit.edu/books/model-checking http://d3s.mff.cuni.cz/teaching/program_analysis_verification/
Teaching @ D3S - Department of Distributed and Dependable Systems d3s.mff.cuni.cz Official web page of the Department of Distributed and Dependable Systems, Charles University, Prague Like Comment Share Automated Testing shared a link. January 26 Model Checking | The MIT Press mitpress.mit.edu Model checking is a technique for verifying finite state concurrent systems such as sequential circuit designs and communication protocols. It has a number of advantages over traditional approaches that are based on simulation, testing, and deductive reasoning. In particular, model checking is autom... Like Comment Share

Automated Testing shared a link. January 26

http://www.pearsonhighered.com/educator/product/Concepts-ofProgramming-Languages-10E/9780131395312.page

http://eu.wiley.com/WileyCDA/WileyTitle/productCd0471137723,descCd-tableOfContents.html

Pearson - Concepts of Programming Languages, 10/E - Robert W. Sebesta www.pearsonhighered.com The account you used to log in on the previous website does not contain IRC access. If you have a separate IRC count, please log in using that login name and password. If you do not have an IRC account, you canrequest access here Like Comment Share

Wiley: Introduction to Computer Theory, 2nd Edition - Daniel I. Like Comment Share A. Cohen eu.wiley.com Automated Testing shared a link. January 25

Automated Testing shared a link. January 25

http://www.bon-method.com/index_normal.htm
BON method: index normal www.bon-method.com

http://www.bon-method.com/computer_annotated.pdf
http://www.bon-method.com/computer_annotated.pdf www.bon-method.com

Like Comment Share Like Comment Share

Automated Testing shared a link. January 24

Automated Testing shared a link. January 24

http://www.akber.com/software-testing
Software Testing - Akber Choudhry www.akber.com Akber A. Choudhry

http://www.cs.columbia.edu/~zeph/
Zeph Grunschlag www.cs.columbia.edu

Like Comment Share Like Comment Share Automated Testing shared a link. January 24

Automated Testing January 24

http://yosefk.com/c++fqa/defective.html
C++ FQA Lite: Defective C++ yosefk.com This page summarizes the major defects of the C++ programming language (listing all minor quirks would take eternity). To be fair, some of the itemsby themselvescould be design choices, not bugs. For example, a programming language doesn't have to provide garbage collection. It's thecombinationof th... Like Comment Share

http://www.cs.virginia.edu/~evans/cs3102-s10/
Like Comment Share

Automated Testing shared a link. January 24

http://math.andrej.com/2008/02/06/representations-ofuncomputable-and-uncountable-sets/
Representations of uncomputable and uncountable sets Mathematics and Computation math.andrej.com Occasionally I hear claims that uncountable and uncomputable sets cannot be represented on computers. More generally, there are all sorts of misguided opinions about representations of data on computers, especially infinite data of mathematical nature. Here is a quick tutorial on the matter whose ma... Like Comment Share

Automated Testing shared a link. January 24

http://lukepalmer.wordpress.com/2012/01/26/computablyuncountable/
Computably Uncountable lukepalmer.wordpress.com We are all familiar with Cantors diagonal argument that proves there exist infinite sets which are larger than the set of natural numbers. In this post I will show that we can ...

Automated Testing January 23

Like Comment Share

http://pdf.aminer.org/000/208/844/ on_transferring_vdm_verification_techniques_to_z.pdf
Like Comment Share

Automated Testing shared a link. January 23

http://itee.uq.edu.au/~ianh/Papers/ndb.pdf
Automated Testing January 23 http://itee.uq.edu.au/~ianh/Papers/ndb.pdf itee.uq.edu.au

What's wrong with UML as a modelling language for design patterns? Giving a full answer to this question would require not one page

Like Comment Share

but an entire encyclopaedia. We are not in the business of writing the seven volumes of What's Wrong with UML; others have already done so successfully (see Bertrand's Meyer's excellent UMLThe Positive Spin.) Rather, let us describe what mechanisms of LePUS3 and Cla...See More
Like Comment Share 1

Automated Testing shared a link. January 23

http://www.lepus.org.uk/ref/companion/faq.xml
FAQ, The 'Gang of Four' Companion www.lepus.org.uk This page is part of the The 'Gang of Four' Companion which details the formal specification of the Abstract Factory design pattern from the 'Gang of Four' catalogue [Gamma et al 1995].

Automated Testing shared a link. January 23

http://www.lepus.org.uk/
LePUS3 and Class-Z Home Page www.lepus.org.uk Visual representations of evidence should be governed by principles of reasoning: Clear and precise seeing becomes as one with clear and precise thinking. -Edward R. Tufte

Like Comment Share

Automated Testing shared a link. January 23

http://www.lepus.org.uk/about.xml
About LePUS3 and Class-Z www.lepus.org.uk LePUS3 and Class-Z are formal objectoriented Design Description Languages. They are formal specification lanaguges for modelling non-functional specifications representing the design of object-oriented class libraries, design patterns, and object-oriented application frameworks (What can be modelle...

Like Comment Share

Automated Testing shared a link. January 23

http://ocw.mit.edu/courses/electrical-engineering-and-computerscience/6-080-great-ideas-in-theoretical-computer-sciencespring-2008/lecture-notes/
Great Ideas in Theoretical Computer Science ocw.mit.edu This course provides a challenging introduction to some of the central ideas of theoretical computer science. It attempts to present a vision of "computer science beyond computers": that is, CS as a set of mathematical tools for understanding complex systems such as universes and minds. Beginning i...

Like Comment Share

Automated Testing shared a link. January 23

http://www.di.ens.fr/~cousot/AI/IntroAbsInt.html
Abstract Interpretation in a Nutshell www.di.ens.fr This introduction to static analysis by abstract interpretation has the objective of being simple, intuitive and informal. More technical introductions as well as bibliographic references are provided in [1,2,3].A 30mnvideo(in French) can also be useful.

Like Comment Share

Like Comment Share

Automated Testing shared a link. January 22

Automated Testing shared a link. January 23

http://www.cengage.com/search/productOverview.do? Ntt=991938321204392568016032450701059771599&N=4294956 584&Ntk=P_EPI


Computer Science - Introduction to the Theory of Computation ,3rdEdition -97811331 www.cengage.com Cengage Learning delivers highly-customized learning solutions for universities, instructors, students, libraries, government agencies, corporations, and professionals worldwide.

http://web.mit.edu/afs/athena.mit.edu/course/16/16.399/www/
MIT Course 16.399: Abstract Interpretation Home Page web.mit.edu Course Objective and Themes: Abstract Interpretation is a theory of approximation of mathematical structures, in particular those involved in the semantic models of computer systems. Abstract interpretation can be applied to the systematic construction of methods and effective algorithms to app... Like Comment Share

Like Comment Share Automated Testing shared a link. January 22 Automated Testing shared a link. January 22

http://www.cs.rpi.edu//~moorthy/Courses/CSCI2400/
http://www.cs.rpi.edu//~moorthy/Courses/CSCI2400/ www.cs.rpi.edu

http://alleystoughton.us/forlan/book.pdf
http://alleystoughton.us/forlan/book.pdf alleystoughton.us

Like Comment Share Like Comment Share Automated Testing January 21 Automated Testing shared a link. January 21

google search: formula model predicate calculus

http://www.math.ryerson.ca/~ddelic/mth714/Ch2handout.pdf
http://www.math.ryerson.ca/~ddelic/mth714/Ch2handout.pd f www.math.ryerson.ca

Like Comment Share

Automated Testing January 21

Like Comment Share

Automated Testing shared a link. January 21

Naime, problem provere da li dati skup formula predikatskog racuna prvog reda ima model je neodluciv, pa cak i ako je specifikacija korektna, nije jasno da li ce program dati rezultat u konacnom vremenu.
Like Comment Share

http://www.math.ryerson.ca/~ddelic/mth714/Ch2handout.pdf
http://www.math.ryerson.ca/~ddelic/mth714/Ch2handout.pd f www.math.ryerson.ca Automated Testing January 21

Undecidable problems
Like Comment Share

Automated Testing shared a link. January 21

Some questions that are undecidable for wider classes of grammars become decidable for context-free grammars; e.g. the emptiness problem (whether the grammar generates any terminal strings at all), is undecidable for context-sensitive grammars, but decidable for context-free grammars. Still, many problems remain undecidable. Examples: [edit] Universality Given a CFG, d...See More
Like Comment Share

http://www.math.ryerson.ca/~ddelic/mth714/mth714.html
Teaching information www.math.ryerson.ca Instructor: Dr Dejan Delic Office: ENG 228Phone: 979-5000 ext 6971 Email:ddelic@ryerson.caOffice hours:Tue 11-12, Wed 3-4, or by appointment

Like Comment Share

Automated Testing shared a link. January 20

Automated Testing shared a link. January 20

http://www.cs.cornell.edu/~kozen/
Dexter Kozen's Home Page www.cs.cornell.edu Research interests: Algorithms and complexity, especially complexity of decision problems in logic and algebra, logics and semantics of programming languages, computer security. Like Comment Share

http://www.amazon.com/Introduction-Theory-ComputationMichael-Sipser/dp/113318779X/ref=sr_1_1? s=books&ie=UTF8&qid=1358692543&sr=1-1
Introduction to the Theory of Computation www.amazon.com Gain a clear understanding of even the most complex, highly theoretical computational theory topics in the approachable presentation found only in the marketleading INTRODUCTION TO THE THEORY OF COMPUTATION, 3E. The number one choice for today's computational theory course, this revision continu... Like Comment Share

Automated Testing shared a link. January 18

http://www.itvestak.org.rs/kadrovi/027.html
Automated Testing shared a link. January 18 IT Vetak www.itvestak.org.rs nalazim se u porodinoj penziji. Odluila sam se na ovaj korak zbog nemogunosti da dalje delujem profesionalno i savesno u situaciji kakva je bila u organima Savezne vlade u to vreme ali i iz porodnnih razloga: iznenadna smrt supruga, nepokretna majka.

http://lara.epfl.ch/~kuncak/papers/vkuncak.html
Viktor Kuncak: Publications and manuscripts lara.epfl.ch

Like Comment Share Like Comment Share Automated Testing shared a link. January 18 Automated Testing shared a link. January 18

http://gigamonkeys.com/book/introduction-why-lisp.html
Introduction: Why Lisp? gigamonkeys.com If you think the greatest pleasure in programming comes from getting a lot done with code that simply and clearly expresses your intention, then programming in Common Lisp is likely to be about the most fun you can

http://www.verifun.org/
http://www.verifun.org/ www.verifun.org

Like Comment Share

have with a computer. You'll get more done, faster, using it than you would using pre... Like Comment Share

Automated Testing shared a link. January 18

http://gigamonkeys.com/book/
Practical Common Lisp gigamonkeys.com This page, and the pages it links to, contain text of the Common Lisp bookPractical Common Lisppublished byApressThese pages now contain the final text as it appears in the book. If you find errors in these pages, please send email tobook@gigamonkeys.com. Th... Like Comment Share

Automated Testing shared a link. January 18

http://www.forum.hr/showthread.php?t=499563
LISP - Forum.hr www.forum.hr LISP Programiranje

Like Comment Share Automated Testing shared a link. January 18

http://www.norvig.com/java-lisp.html
Lisp as an Alternative to Java www.norvig.com It turns out my hopes were answered. First, Prechelt publishedanother articlethat covers Tcl, Python, Perl, and Rexx. Also,Ron Garret (nee Erann Gat)did afollow-up studyin which he asked programmers to write Prechelt'stest programin Lisp. His results show that the resulting Lisp programs ran faster ... Like Comment Share

Automated Testing shared a link. January 18

An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl for a search/string-processing program http://page.mi.fuberlin.de/prechelt/Biblio/jccpprtTR.pdf
http://page.mi.fu-berlin.de/prechelt/Biblio/jccpprtTR.pdf page.mi.fu-berlin.de

Like Comment Share

Automated Testing shared a link. January 18

Automated Testing shared a link. January 17

http://page.mi.fu-berlin.de/prechelt/Biblio/jccpprtTR.pdf
http://page.mi.fu-berlin.de/prechelt/Biblio/jccpprtTR.pdf page.mi.fu-berlin.de

http://www.coned.de/de/home/
ConEd: HOME www.coned.de Der Conceptual Engineering Editor, kurz ConED ist Ihr mageschneidertes Werkzeug fr die Leistungsphasen 2 und 3, um Tragkonzepte zu erstellen. Entstanden aus den Anforderungen der Praxis. Durch Ingenieure tagtglich erprobt und konsequent verbessert an konkreten Projekten. Mit durchdachten Funktion... Like Comment Share

Like Comment Share

Automated Testing shared a link. January 17

http://franklinchen.com/blog/2011/10/25/rip-john-mccarthy-butlisp-will-never-die/
RIP, John McCarthy; but Lisp will never die - Franklin Chen's grain of sand franklinchen.com RIP, John McCarthy; but Lisp Will Never Die Oct 25th, 2011 Permalink(Updated 2012-01-16)The legendary computer scientist John McCarthy died yesterday. So there goes another guy without whom my life today would be unimaginably different: Steve Jobs and Dennis Ritchie just left us this month!In a wa... Like Comment Share

Automated Testing January 17

Most papers in computer science describe how their author learned what someone else already knew. - Peter Landin (This is a paraphrase. I'd appreciate it if anyone can tell me the exact quote.)
Like Comment Share 1

Automated Testing shared a link. January 17

Automated Testing shared a link. January 17

http://www.paulgraham.com/quotes.html http://www.trollope.org/scheme.html
Lisp Quotes www.paulgraham.com A Scheme Story www.trollope.org My first classin computer programming was an elective course in BASIC back in sixth grade. I chose that class because I thought that computers were powerful and capable of doing many interesting things. Electives usually have a reputation for being fun, but my classmates and I heard stories about th... Like Comment Share

Like Comment Share

Automated Testing shared a link. January 17

http://kuomarc.wordpress.com/2012/01/27/why-i-love-commonlisp-and-hate-java/
Why I love Common Lisp and hate Java kuomarc.wordpress.com Common what? is a common reply I get when I mention Common Lisp. Perhaps rightly so, since Common Lisp is not all that common these days. Developed in the sixties, it is one of the ol... Automated Testing shared a link. January 17

http://www.paulgraham.com/avg.html
Beating the Averages www.paulgraham.com April 2001, rev. April 2003(This article is derived from a talk given at the 2001 Franz Developer Symposium.) In the summer of 1995, my friend Robert Morris and I started a startup called Viaweb. Our plan was to write software that would let end users build online stores. What was novel about this s... Like Comment Share

Like Comment Share

Automated Testing shared a link. January 15

http://speely.wordpress.com/2011/10/26/prefix-postfix-newfixbluefix/
Prefix, Postfix, Newfix, Bluefix speely.wordpress.com My, my, look at all those notations. You can infix: 2 + 2. You can prefix: + 2 2. You can postfix: 2 2 +. All three notations are perfectly arbitrary for the purposes of mathematics. (2 + 2) * &hel...

Automated Testing shared a link. January 15

http://speely.wordpress.com/tag/haskell/
Posts about haskell on Speely speely.wordpress.com Posts about haskell written by mcandre

Like Comment Share

Automated Testing shared a link. January 14

Like Comment Share

http://cacm.acm.org/magazines/2013/1/158780-who-begatcomputing/fulltext
Who Begat Computing? cacm.acm.org The Turing Centenary is now behind us and we can afford some reflection on what has transpired. There is a risk, however, that in our focus on highlighting Turing's seminal contributions we may have gone from celebration to hagiography.

Automated Testing shared a link. January 13

http://www03.ibm.com/ibm/history/exhibits/builders/builders_backus3.html Von Neumanns concept was brilliant. of course, and worked fine 30 years ago, said Backus. But, he paused, making arches of his hands, heres my highly oversimp...See More
IBM Archives: John Backus page 3 www-03.ibm.com

Like Comment Share

Automated Testing shared a link. January 13

John Backus was the developer of FORTRAN, for years one of the best known and most used programming systems in the world.

"Principles of Computer Programming: A Mathematical Approach" by Harlan D. Mills, Victor R. Basili e trace.tennessee.edu Mills, Harlan D.; Basili, Victor R.; Gannon, John D.; and Hamlet, Richard D., "Principles of Computer Programming: A Mathematical Approach" (1988). The Harlan D. Mills Collection.http://trace.tennessee.edu/ut k_harlan/7

Like Comment Share

Automated Testing shared a link. January 10

http://planet.haskell.org/
Planet Haskell planet.haskell.org Working on DuDuHoX is increasingly difficult. I've thought about giving up on some problems I had, either with code or libraries.

Like Comment Share

Automated Testing shared a link. January 10

http://www.dnull.com/cpu/backus.pdf Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs John Backus IBM Research Laboratory, San Jose
http://www.dnull.com/cpu/backus.pdf www.dnull.com Like Comment Share

Automated Testing shared a link. January 10

http://www.cambridge.org/gb/knowledge/isbn/item1163819/? site_locale=en_GB "The functional style is quite different to that promoted by most current languages, such as Java, C++, C, and Visual Basic. In particular, most current languages ar...See More

Like Comment Share

Automated Testing shared a link. January 9

http://www.cambridge.org/gb/knowledge/isbn/item1163819/? site_locale=en_GB
Programming in Haskell www.cambridge.org Haskell is one of the leading languages for teaching functional programming, enabling students to write simpler and cleaner code, and to learn how to structure and reason about programs. This introduction is ideal for beginners: it requires no previous programming experience and all concepts are exp... Like Comment Share

Programming in Haskell Like Comment Share www.cambridge.org Haskell is one of the leading languages for teaching functional programming, enabling students to write simpler and cleaner code, and Automated Testing shared a link. to learn how to structure and reason about programs. This introduction January 9 is ideal for beginners: it requires no previous programming experience and all concepts are exp...

http://sources.haskell.cz/
Index of / sources.haskell.cz

Automated Testing shared a link. January 9

Like Comment Share

http://www.cs.nott.ac.uk/~gmh/book.html#slides
Slides - Programming in Haskell www.cs.nott.ac.uk These slides may be freely used or modified for any educational or training purpose, provided that I am acknowledged as the original author. Automated Testing shared a link. January 9

http://nptel.iitm.ac.in/video.php?subjectId=106101061
NPTEL PHASE 2 - Courses nptel.iitm.ac.in

Like Comment Share Like Comment Share Automated Testing January 8

Automated Testing shared a link. January 8

Von Neuman Architecture https://ocaml.janestreet.com/?q=node%2F61


Caml Trading talk at CMU | ocaml.janestreet.com ocaml.janestreet.com I was at CMU several weeks ago, and gave a version of my "Caml Trading" talk there. See below if you are interested in seeing the video. It's a reasonably good source if you're interested in understanding more about how and why Jane Street uses OCaml.

Like Comment Share

Automated Testing shared a link. January 8

http://book.realworldhaskell.org/read/
Real World Haskell book.realworldhaskell.org Copyright 2007, 2008 Bryan O'Sullivan, Don Stewart, and John Goerzen. This work is licensed under a Creative Commons AttributionNoncommercial 3.0 License. Icons by Paul Davey aka Mattahan. Like Comment Share Like Comment Share

Automated Testing shared a link. January 8

Automated Testing shared a link. January 8

http://www.stacken.kth.se/project/yxa/
YXA www.stacken.kth.se 2007-11-05: YXA 1.0 is released! Two years after the first stable release, a very stable and mature SIP server is available. Enjoy.

http://blog.alainodea.com/en/article/393/nearly-defect-freesoftware-with-erlang
Nearly defect-free software with Erlang Concise Software Alain O'Dea blog.alainodea.com

Like Comment Share

Like Comment Share

Automated Testing shared a link. January 8

Automated Testing shared a link. January 8

http://reprog.wordpress.com/2010/03/11/the-differencebetween-imperative-and-functional-programming/
The difference between imperative and functional programming reprog.wordpress.com Have you ever had this frustrating experience? You need to drive somewhere that youve not been before, so you look that place up on the web. You find its site, and start looking through th...

https://github.com/lemenkov/erlrtpproxy
erlrtpproxy github.com RTP/RTCP proxy for VoIP and IM applications. Contribute to erlrtpproxy development by creating an account on GitHub.

Like Comment Share

Like Comment Share

Automated Testing shared a link. January 8

Automated Testing shared a link. January 7

http://blog.alainodea.com/en/article/393/nearly-defect-freesoftware-with-erlang
Nearly defect-free software with Erlang Concise Software Alain O'Dea blog.alainodea.com

http://www.slideshare.net/wooga/erlang-factory-sanfran
Erlang and the Cloud: A Fractal Approach to Throughput www.slideshare.net Erlang as a cloud citizen Paolo Negri @hungryblank

Like Comment Share

Like Comment Share

Automated Testing shared a link. January 7

http://smyck.net/2012/04/22/why-erlang/
Automated Testing shared a link. January 7 Why Erlang? | SMYCK smyck.net Why Erlang?Posted on April 22, 2012 by huklThe chance that you are reading this blog post on a device with a multicore cpu is increasing on a daily basis which is why everybody is talking about concurrency now. Concurrency for our web applications and API backends means that wed like our htop to lo...

http://www.javalimit.com/2011/05/erlang-is-not-a-concurrentfunctional-programming-language.html
Erlang is not a Concurrent Functional Programming Language Java to the Limit www.javalimit.com Whenever developers fall in love with Erlang (as many tend to do these days) they are too often busy promoting it to their friends and colleagues as a cool language for *concurrency* and *functional programming*. Which is a pity, for... Like Comment Share

Like Comment Share

Automated Testing shared a link. January 7

http://learnyousomeerlang.com/
Automated Testing shared a link. January 7 Learn You Some Erlang for Great Good! learnyousomeerlang.com Learn you some Erlang for great good! An Erlang tutorial for beginners and others too.

http://users.softlab.ntua.gr/~ttsiod/score4.html
Programming AI using functional and imperative languages users.softlab.ntua.gr I recently took a one week vacation and went to my parent's village. My niece Theodora was there (she is 7 years old), spending a fortnight with her grandparents. Naturally, in my duties as her uncle, I read her fairy tales when she went to sleep; gave her my phone so she could snap photos and play ...

Like Comment Share

Automated Testing shared a link. January 7

Like Comment Share

http://thesistime.blogspot.com/2008/10/haskell-vs-ada-vs-c-vsawk-vs.html
ThesisTime: Haskell vs. Ada vs. C++ vs. Awk vs. ... thesistime.blogspot.com The idea was to ask to an expert for each language to do a prototype of the requirement. The experts have two meetings before starting to work in where the problem was described. After that they should work on their prototypes and report the time it took to develop it, the number of lines of code an... Like Comment Share

Automated Testing shared a link. January 7

http://www.haskell.org/papers/NSWC/jfp.ps
http://www.haskell.org/papers/NSWC/jfp.ps www.haskell.org

Like Comment Share

Automated Testing shared a link. January 7

Automated Testing January 7

http://jaskell.codehaus.org/
Jaskell - Home jaskell.codehaus.org Jaskell is a functional scripting programming language that runs in JVM. The name "Jaskell" stands for JavaHaskell, Haskell being the famous pure functional programming language.

Like Comment Share

"Conventional programming languages are growing ever more enormous, but not stronger. Inherent defects at the most basic level cause them to be both fat and weak: their primitive wordat-a-time style of programming inherited from their common ancestor -- the von Neumann computer, their close coupling of semantics to state transitions, their division of programming into a world of expressions and a world of statements, their inability to effectively use powerful combining forms for building new programs from existing ones, and their lack of useful mathematical properties for reasoning about programs." John Backus, known for Fortran, Algol and BNF
Like Comment Share

Automated Testing January 7

"You wanted a banana but what you got was a gorilla holding the banana and the entire jungle." Joe Armstrong, creator of Erlang
Like Comment Share

Automated Testing shared a link. January 7

igstan.ro/files/functional-programming.pdf
http://igstan.ro/files/functional-programming.pdf igstan.ro Automated Testing shared a link. January 7 Like Comment Share

http://www.cl.cam.ac.uk/~jrh13/slides/funprog-jrh/
Index of /~jrh13/slides/funprog-jrh www.cl.cam.ac.uk Automated Testing shared a link. January 7

Introduction to Functional Programming - University of Cambridge


Like Comment Share http://www.cl.cam.ac.uk/~jrh13/slides/funprog-jrh/l1.pdf www.cl.cam.ac.uk Automated Testing shared a link. January 5 Like Comment Share

http://fpcomplete.com/the-downfall-of-imperative-programming/
The Downfall of Imperative Programming | FP Complete fpcomplete.com The Downfall of Imperative ProgrammingApril 9, 2012by Bartosz Milewski | 80 CommentsImperative programming is in my bloodstream. Ive been a C++ programmer for most of my life. I wrote a book about C++. I helped Andrei and Walter design an imperative language D. If I dabbled in functional programmin... Like Comment Share Automated Testing shared a link. January 5

http://misko.hevery.com/2008/09/10/where-have-all-the-newoperators-gone/
Where Have all the new Operators Gone? misko.hevery.com In My main() Method Is Better Than Yours we looked into what a main() method should look like. There we introduced a clear separation between (1) the responsibility of constructing the object graph and (2) the responsibility of running the application. The reason that this separation is important wa... Like Comment Share

Automated Testing shared a link. January 5

http://stackoverflow.com/questions/602444/what-is-functionaldeclarative-and-imperative-programming/8357604#8357604
terminology - What is functional, declarative and imperative programming? - Stack Overflow stackoverflow.com Functional programming is a subtype of declarative programming. So you've really asked the question "what is functional/declarative programming versus imperative programming"?

Like Comment Share

Show all stories from 2013

Launched

Automated Testing shared a link. December 31, 2012

Likes
2012

http://www.adacore.com/sparkpro/tokeneer/discovery
Tokeneer Discovery Tutorial | Tokeneer | SPARK Pro | AdaCore www.adacore.com This tutorial provides an introduction to the SPARK programming language and Toolset for engineering high-assurance software using the source code from the Tokeneer Project. It contains a series of lessons that demonstrates key features of the language and Toolset, illustrating why SPARK is superior... Like Comment Share

Automated software testing

Implementing Automated Software Testing

Automated Testing shared a link. December 31, 2012

http://www.adacore.com/sparkpro/tokeneer
Automated Testing shared a link. December 31, 2012 Tokeneer | SPARK Pro | AdaCore www.adacore.com In order to demonstrate that developing highly secure systems to the level of rigor required by the higher assurance levels of the Common Criteria is possible, the NSA (National Security Agency) asked Altran Praxis to undertake a research project to develop part of an existing secure system (the Tok...

http://www.altran-praxis.com/spark.aspx
Altran Praxis : Technology : SPARK www.altran-praxis.com Altran Praxis is a systems and software house. We are experts, focused on the engineering of systems with demanding safety, security or innovation requirements within Systems, Software and Safety Engineering, Innovation Management and Training. Altran Praxis is based in Bath, London and Loughborough... Like Comment Share

Like Comment Share

Automated Testing shared a link. December 25, 2012

http://www.testingstuff.com/
Automated Testing shared a link. December 25, 2012 Software Testing Stuff www.testingstuff.com Reference site for software quality and testing information including associations, tools, training, services, articles, conferences, and references.

http://www.objectiver.com/index.php?id=6
Objectiver: Documentation www.objectiver.com KAOS Tutorial (5.3 Mb) This tutorial covers the KAOS method, concepts and modeling techniques for analysing project requirements.

Like Comment Share

Like Comment Share

Automated Testing shared a link. December 25, 2012

http://www.testinginstitute.com/
Automated Testing shared a link. December 25, 2012 International Institute for Software Testing (IIST) CSTP & CTM Informational Home Page www.testinginstitute.com IIST is a software testing educational and professional development organization that is dedicated to advancing the software test profession through education and certification of software test professionals

http://www.grove.co.uk/
Grove Consulting, Specialists in Software Testing | Grove Consultants www.grove.co.uk Like Comment Share Grove Consulting are specialists in software testing and provide training for ISTQB and ISEB qualifications as well as a variety of other testing based courses. Automated Testing December 25, 2012

Like Comment Share

Automated Testing shared a link. December 25, 2012

http://bazman.tripod.com/checklist.html? button1=GUI+Testing+Checklist

Software Engineering Process Technology (SEPT): Software Test Standards, by Stan Magee IEEE Standard for Software Test Documentation (ANSI/IEEE Std. 829-1983) IEEE Standard for Software Unit Testing (ANSI/IEEE Std. 10081987) IEEE Standard for Software Verification and Validation Plans (IEEE Std. 1012-1986) IEEE Guide for Software Verification and Validation Plans (IEEE Std. 1059-1993)
Like Comment Share

Like Comment Share

Automated Testing shared a link. December 25, 2012

http://bazman.tripod.com/
GUI Testing Checklist bazman.tripod.com GUI Testing checklist intended for training new gui software testers & testing gui interfaces. May be usefulafor unit testing also. Automated Testing shared link. December 24, 2012 Bazman's Testing Pages bazman.tripod.com Software test plan, test plan contents, full contents of a system test plan, GUI Testing checklist intended for training new gui software testers & testing gui interfaces, test setup checklist, test planning tasklist. Like Comment Share

http://agile.csc.ncsu.edu/SEMaterials/tutorials/metrics/
Software Metrics agile.csc.ncsu.edu Laurie Williams, Dright Ho, and Sarah Heckman. [Contact Authors]CSC 326 Software Engineering Department of Computer ScienceNorth Carolina State University Like Comment Share

Automated Testing shared a link. December 24, 2012

http://www.openseminar.org/se/modules/6/index/screen.do
Software Engineering > Object-Oriented Metrics www.openseminar.org

Automated Testing shared a link. December 24, 2012

http://www.ipipan.gda.pl/~marek/objects/TOA/moose.html
Metrics for Object-Oriented Software Engineering www.ipipan.gda.pl In most conventional software (e.g., software created using functional decomposition), localization is based on functionality. Therefore:

Object-oriented (OO) metrics are measurements on OO applications used to determine the success or failure of a process or person, and to quantify improvements throughout the software process. These metrics can be used to reinforce good OO programming techniques, which leads to more reliable code. Like Comment Share

Automated Testing shared a link. December 24, 2012

Like Comment Share

http://www.sei.cmu.edu/library/abstracts/reports/93em007.cfm
Library | Materials for Teaching Software Inspections www.sei.cmu.edu This 1993 report includes materials for demonstrating how to perform an inspection and sell students on the effectiveness of inspections.

Automated Testing shared a link. December 24, 2012

http://agile.csc.ncsu.edu/SEMaterials/OOMetrics.htm

Like Comment Share

2.2 Cohesion Cohesion refers to how closely the operations in a class are related to each other. Cohesion of a class is the degree to which the local methods are related to the local...See More
Object-Oriented Metrics agile.csc.ncsu.edu Increasingly, object-oriented measurements are being used to evaluate and predict the quality of software [16]. A growing body of empirical results supports the theoretical validity of these metrics [3, 5, 14, 19]. The validation of these metrics requires convincingly demonstrating that (1) the metr... Like Comment Share

Automated Testing shared a link. December 21, 2012

http://www.softdocwiz.com/UML.htm
Softdocwiz.com - UML Dictionary www.softdocwiz.com A generalizable element is abstract if it cannot be directly instantiated. See the entries for abstract class, abstract operation, and abstract use case for more specific information.

Like Comment Share Automated Testing shared a link. December 19, 2012

Automated Testing December 19, 2012

http://nptel.iitm.ac.in/video.php?subjectId=106101061
NPTEL PHASE 2 - Courses nptel.iitm.ac.in

Coupling example http://pmd.sourceforge.net/pmd5.0.1/rules/java/coupling.html

Like Comment Share

Automated Testing December 19, 2012

Cyclomatic complexity 12 from http://phpmd.org/rules/codesize.html

Like Comment Share

Like Comment Share

Automated Testing December 15, 2012

Automated Testing shared a link. December 18, 2012

Oral history of Watts Humphrey "The reason its so extraordinary is that when you make a mistake-- and I tried to eliminate my mistakes, and I literally couldnt do it. I found that there was no way that I could write programs without making errors. And the reason was that I was human, contrary to popular opinion, right? But there was no way I could literally do it. Because I was human, I tended ...See More
Like Comment Share

http://www.freetechbooks.com/
Free Online Computer Science and Programming Books, Textbooks, and Lecture Notes www.freetechbooks.com Free online computer science, engineering and programming books, ebooks, texts, textbooks, lecture notes, documentations and references.

Like Comment Share

Automated Testing December 15, 2012

http://www.altran.com/
Like Comment Share

Automated Testing shared a link. December 15, 2012

Automated Testing shared a link. December 15, 2012

http://libre.adacore.com/tools/spark-gpl-edition/
SPARK GPL Edition | Tools | Libre libre.adacore.com SPARK GPL Edition 2012 GPL Edition Now Available! SPARK GPL provides the foremost language, toolset and design discipline for the engineering of high-assurance software. It combines the renowned SPARK language and verification tools from Altran Praxis with the GNAT Programming Studio (GPS) and GNATB... Like Comment Share

http://www.sans.org/top25-software-errors/
SANS: CWE/SANS TOP 25 Most Dangerous Software Errors www.sans.org The top 25 most dangerous software programming errors courtesy of CWE and the SANS Institute.

Like Comment Share

Automated Testing shared a link. December 11, 2012

Automated Testing shared a link. December 15, 2012

http://www.overturetool.org/?q=node%2F13
VDM++ examples for Overture | Overture www.overturetool.org

http://www.altran-praxis.com/spark.aspx
Altran Praxis : Technology : SPARK www.altran-praxis.com Altran Praxis is a systems and software house. We are experts, focused on the engineering of systems with demanding safety, security or innovation requirements within Systems, Software and Safety Engineering, Innovation Management and Training. Altran Praxis is based in Bath, London and Loughborough... Like Comment Share

Like Comment Share

Automated Testing shared a link. December 10, 2012

Automated Testing shared a link. December 11, 2012

http://www.vdmbook.com/twiki/bin/view
WebHome < Main < VdmBook www.vdmbook.com

http://www.palgrave.com/products/title.aspx?pid=265283
Software Development with UML : Ken Lunn : Palgrave Macmillan www.palgrave.com Palgrave Macmillan is a global academic publisher, serving learning and scholarship in higher education and the professional world

Like Comment Share

Like Comment Share

Automated Testing shared a link. December 8, 2012

Automated Testing shared a link. December 8, 2012

http://www.sqale.org/
SQALE | Software Quality Assessment based on Lifecycle Expectations www.sqale.org The method is the property of inspearit (formally DNV ITGS France), it is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported license. Like Comment Share

http://www.sonarsource.org/sonar-3-3-in-screenshots/
Sonar Sonar 3.3 in Screenshots www.sonarsource.org SONAR is an open source quality management platform, dedicated to continuously analyze and measure source code quality, from the portfolio to the method. Like Comment Share

Automated Testing shared a link. December 8, 2012

Automated Testing December 8, 2012

http://www.sonarsource.org/
Sonar www.sonarsource.org SONAR is an open source quality management platform, dedicated to continuously analyze and measure source code quality, from the portfolio to the method. Like Comment Share

http://vimeo.com/43523820
Like Comment Share

Automated Testing shared a link. December 8, 2012

http://www.informit.com/articles/article.aspx?p=457502
The Bad Code Spotter's Guide | Poor Commenting | InformIT www.informit.com Old maps were marked with the phrase "Here be Dragons" to help seafarers steer away from dangerous places; in programming the best way to avoid dealing with bad code is to avoid writing it. Diomidis Spinellis points out 10 giveaways to spot bad code that you (or others) Like Comment Share may have written.

Automated Testing shared a link. December 8, 2012

http://www.spinellis.gr/codequality/
Spinellis: Code Quality: The Open Source Perspective www.spinellis.gr Support page for Code Quality: The Open Source Perspective: Overview, discussion of approach, table of contents, reviews, errata, the making of.

Automated Testing shared a link. December 7, 2012

Like Comment Share

http://www.codinghorror.com/blog/2006/05/code-smells.html
Coding Horror: Code Smells www.codinghorror.com

Automated Testing shared a link. December 6, 2012

http://msmvps.com/blogs/peterritchie/archive/2008/05/08/funda mentals-of-ood-part-2-encapsulation-scope.aspx
Like Comment Share Fundamentals of OOD, Part 2 - Encapsulation Scope - Peter Ritchie's MVP Blog msmvps.com MVP's worldwide

I'm often asked why the book Refactoring isn't included in my recommended developer reading list. Although I own the book, and I've read it twice, I felt it was too prescriptive-- if you see (x), then you must do (y). Any programmer worth his or her salt should already be refactoring aggressively. I...

Automated Testing shared a link. December 6, 2012

Like Comment Share

http://msmvps.com/blogs/peterritchie/archive/2008/06/10/funda mentals-of-ood-part-3-method-cohesion.aspx

Automated Testing shared a link. December 6, 2012

Fundamentals of OOD Part 3: Method Cohesion - Peter Ritchie's MVP Blog msmvps.com MVP's worldwide

Example of non-cohesive methods http://www.scribd.com/doc/115766203/Example-of-NonCohesive-Methods


http://www.scribd.com/doc/115766203/Example-of-NonCohesive-Methods www.scribd.com

Like Comment Share

Automated Testing shared a link. December 6, 2012

Like Comment Share

http://pragprog.com/magazines/2010-12/cohesive-softwaredesign
The Pragmatic Bookshelf | PragPub December 2010 | Cohesive Software Design pragprog.com Books, screencasts, forums, articles, and more, all aimed at helping software developers get better and have more fun. Our titles are available on paper and electronically, and all our ebooks are DRM-free. Enjoy! Like Comment Share

Automated Testing December 6, 2012

Tools supported by TIOBE's product TICS http://www.tiobe.com/index.php/content/TICS/FactSheet.html

Automated Testing December 5, 2012

Language Code Checker Test Coverage Cyclomatic Complexity C/C++ TICSpp/TICSc (TIOBE internal code checkers) VectorCAST (Vector Software) SourceMonitor (Campwood) C++Test (Parasoft) C++Test (Parasoft) QA-C/C++ (Programming Research) BullseyeCoverage (Bullseye) PC-Lint (Gimpel) CTC++ (Testwell) CodeSonar (GrammaTech) gcov/lcov (SourceForge) C# FxCop (Microsoft) NCover (NCover) StyleCop (Microsoft) J...See More
Like Comment Share

Automated Testing shared a link. December 5, 2012 Like Comment Share

http://cobertura.sourceforge.net/
Cobertura cobertura.sourceforge.net Cobertura is a Java code coverage analysis tool. You can use it to determine what percentage of your source code is excercised by your unit tests.

Automated Testing shared a link. December 5, 2012

Example of Method with Cyclomatic Complexity 202 www.scribd.com MapsMIDlet.jaa lxxxi All classes and interfaces must belong to a named package 17 PMD Marker Avoid really long classes. 17 PMD Marker Efferent Couplings is 36 17 Metrics Marker Lack of Cohesion in Methods (Henderson-Sellers) is 90% 17 Metrics Marker Lack of Cohesion in Methods (Total Like Comment Share Correlation) i...

Like Comment Share

Automated Testing December 3, 2012

Automated Testing December 3, 2012

NPathComplexity - NPATH metric computes the number of possible execution paths through a function. It takes into account the nesting of conditional statements and multi-part boolean expressions (e.g., A && B, C || D, etc.). Rationale: Nejmeh says that his group had an informal NPATH limit of 200 on individual routines; functions that exceeded this value were candidates for further decomposition - or at least a closer look.
Like Comment Share

CyclomaticComplexity - checks cyclomatic complexity against a specified limit. The complexity is measured by the number of if, while, do, for, ?:, catch, switch, case statements, and operators && and || (plus one) in the body of a constructor, method, static initializer, or instance initializer. It is a measure of the minimum number of possible paths through the source and therefore the number of required tests. Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
Like Comment Share

Automated Testing shared a link. November 29, 2012

https://www.coursehero.com/

Automated Testing shared a link. November 29, 2012

http://www.overturetool.org/?q=home
Welcome to the Overture tool project | Overture www.overturetool.org Overture is a community-based project developing the next generation of opensource tools to support modelling and analysis in the design of computerbased systems. Overture supports VDM: The Vienna Development Method, a set of modelling techniques with a long and successful history of industrial ap...

Course Hero | Study Guides, Lecture Notes, Flashcards, Practice Exams, Lecture Videos | The best way www.coursehero.com

Like Comment Share

Automated Testing shared a link. November 29, 2012

Like Comment Share

http://kurser.iha.dk/eit/tivdm1/groups.html
Model-drevet udvikling med VDM++ og UML 1 (TIVDM1) - Forr 2010 kurser.iha.dk

Automated Testing shared a link. November 21, 2012

http://computationaltales.blogspot.co.nz/
Computational Fairy Tales computationaltales.blogspot.co.nz Like Comment Share Like Comment Share

Automated Testing shared a link. November 21, 2012 Automated Testing shared a link. November 21, 2012

GREAT PRINCIPLES OF COMPUTING


welcome cs.gmu.edu

http://csunplugged.org/unplugged-teachers
Unplugged for Teachers | Computer Science Unplugged csunplugged.org The activities for Computer Science Unplugged are easy to integrate into a classroom program. Each is a self-contained lesson plan, and it's easy to... Like Comment Share Like Comment Share

Automated Testing shared a link. November 20, 2012

Automated Testing shared a link. November 20, 2012

http://pmd.sourceforge.net/
PMD pmd.sourceforge.net PMD is a source code analyzer. It finds unused variables, empty catch blocks, unnecessary object creation, and so forth.

http://www.eclipse.org/tptp/home/documents/process/developm ent/static_analysis/TPTP_static_analysis_tutorial_part1.html
TPTP static analysis tutorial part 1 www.eclipse.org The Eclipse Test & Performance Tools Platform (TPTP) is a powerful tool for evaluating the overall performance and quality of Java source code. In addition to well-known features for measuring code performance, TPTP now includes a framework that offers the user a uniform focus for all forms of stat... Like Comment Share

Like Comment Share

Automated Testing shared a link. November 20, 2012

Automated Testing shared a link. November 20, 2012

http://findbugs.sourceforge.net/
FindBugs - Find Bugs in Java Programs findbugs.sourceforge.net This is the web page for FindBugs, a program which uses static analysis to look for bugs in Java code. It is free software, distributed under the terms of theLesser GNU Public License. The name FindBugs and theFindBugs logoare trademarked byThe University of Maryland. FindBugs ...

http://andrei.gmxhome.de/jdepend4eclipse/
JDepend plugin for Eclipse: JDepend4Eclipse andrei.gmxhome.de JDepend4Eclipse plugin for Eclipse is a wrapper for running JDepend from within Eclipse, written by Andrey Loskutov

Like Comment Share

Like Comment Share

Automated Testing November 19, 2012

Automated Testing shared a link. November 20, 2012

http://codedependents.com/2009/07/01/top-5-static-analysis-

Nov 19, 2012 7:52pm

plugins-for-eclipse/
Top 5 Static Analysis Plugins for Eclipse codedependents.com Static Analysis How is it that static analysis is still a best kept secret while so much lips service is paid to code reviews? We have long since understood that boring repetitive jobs should be l...

Like Comment Share

Automated Testing shared a link. November 19, 2012

http://standards.ieee.org/findstds/standard/1044-1993.html
IEEE SA - 1044-1993 - IEEE Standard Classification for Software Anomalies standards.ieee.org A uniform approach to the classification of anomalies found in software and its documentation is provided. The processing of anomalies discovered during any software life cycle phase are described, and comprehensive lists of software anomaly classifications and related data items that are helpful to... Like Comment Share

Like Comment Share

Automated Testing shared a link. November 16, 2012

1. Introduction to Function Points A structured technique of problem solving, function point analysis is a method to break systems into smaller components, so they can be better understood and... Automated Testing shared a link. November 16, 2012

http://www.testinginstitute.com/cstpm.php
Certified Software Test Professional Master Level (CSTP-M) www.testinginstitute.com IIST provides testing for Software Testing Certification

Like Comment Share

Automated Testing shared a video. November 16, 2012

Fixing Software Design Defects part 3 Fixing Software Design Defects part 3

Like Comment Share

Automated Testing shared a link. November 14, 2012

http://www.springer.com/computer/swe/book/978-0-85729-2766
Specification of Software Systems www.springer.com Recent advances in software specification methods, model checking, and theorem proving have generated new tools for the use of formal methods in both industry and academia. Yet, in order to choose the techniques most appropriate ... Like Comment Share

Like Comment Share

Automated Testing shared a link. November 9, 2012

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/process/tsp/
SEI Certification | Process Improvement | TSP Coach www.sei.cmu.edu Be accepted into the program as a candidate after submission of all documentation described above. Then successfully complete the SEIsTSP Coach Training course. Upon graduation from the TSP Coach Training course, candidates must complete the mentoring program as detailed below. Like Comment Share

http://www.sei.cmu.edu/certification/process/psp-instructor/
SEI Certification | Process Improvement | PSP Instructor www.sei.cmu.edu PSP Instructor

Like Comment Share

Automated Testing shared a link. November 9, 2012

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/architecture/dsa/
SEI Certification | Software Architecture | Documenting Software Architectures Instructor www.sei.cmu.edu Effectively documenting a software architecture is as important as crafting it. As a Documenting Software Architectures (DSA) instructor, you'll be qualified to train others in effective software architecture documentation practices that meet the needs of the entire architecture stakeholder communit... Like Comment Share

http://www.sei.cmu.edu/certification/process/psp/
SEI Certification | Process Improvement | PSP Developer www.sei.cmu.edu The SEI Personal Software Process is a disciplined and structured approach to software development that can be applied to many different types of projects. As an SEI-Certified PSP Developer, you have the knowledge and skills to competently deliver quality software on predictable schedulesand the SE... Like Comment Share

Automated Testing shared a link. November 9, 2012

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/process/pcmm-instructor/
SEI Certification | Process Improvement | People CMM Instructor www.sei.cmu.edu People CMM Instructor

http://www.sei.cmu.edu/certification/architecture/atam/
SEI Certification | Software Architecture | Architecture Tradeoff Analysis Method Leader | Architect www.sei.cmu.edu The Software Engineering Institute ATAM is used to evaluate software architectures relative to quality attribute goals. An ATAM exposes architectural risks that could inhibit the achievement of an organization's business goals. Like Comment Share

Like Comment Share

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/measurement/dppss/
SEI Certification | Measurement & Analysis | Designing Products and Processes Using Six Sigma www.sei.cmu.edu Become an SEI-Certified Instructor for Designing Products and Processes Using Six Sigma

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/measurement/igdm/
SEI Certification | Measurement & Analysis | Implementing Goal-Driven Measurement Instructor | Instr www.sei.cmu.edu An Implementing Goal-Driven Measurement (IGDM) Instructor introduces the methods for identifying and defining indicators (graphical displays) and measures that directly support an organizations business goals related to product development, process improvement, and project management. Like Comment Share

Like Comment Share

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/measurement/ippss/
SEI Certification | Measurement & Analysis | Improving Process Performance Using Six Sigma www.sei.cmu.edu Become an SEI-Certified Instructor for Improving Process Performance Using Six Sigma

Automated Testing shared a link. November 9, 2012

http://www.sei.cmu.edu/certification/measurement/igdm/
SEI Certification | Measurement & Analysis | Implementing Goal-Driven Measurement Instructor | Instr www.sei.cmu.edu An Implementing Goal-Driven Measurement (IGDM) Instructor introduces the methods for identifying and defining indicators (graphical displays) and measures that directly support an organizations business goals related Like Comment Share to product development, process improvement, and project management.

Like Comment Share

Automated Testing shared a link. November 5, 2012

AntiPatterns sourcemaking.com AntiPatterns, like their design pattern counterparts, define an industry vocabulary for the common defective processes and implementations within organizations. A higher-level vocabulary simplifies communication between software practitioners and enables concise description of higher-level concepts.

Automated Testing shared a link. November 5, 2012

UML sourcemaking.com Most books aboutUMLdescribe it almost in its entirety. Inevitably youre left with only a superficial knowledge of the range ofUMLelements, without a deep and intuitive understanding of how to applyUMLas a whole to real world design problems. This book doesnt set out to cover all ofUML, but instead... Like Comment Share

Like Comment Share

Automated Testing shared a link. November 2, 2012

http://www.doc.ic.ac.uk/~jnm/book/

Automated Testing shared a link. November 2, 2012

http://www.doc.ic.ac.uk/~jnm/book/book_applets/concurrency.ht ml

Concurrency: models and programs www.doc.ic.ac.uk

Like Comment Share Like Comment Share Concurrency - State Models & Java Programs www.doc.ic.ac.uk

Automated Testing shared a link. November 2, 2012

Automated Testing October 30, 2012

http://www.doc.ic.ac.uk/~jnm/book/
Concurrency - State Models & Java Programs www.doc.ic.ac.uk

Oct 31, 2012 12:13am


ArgoUML in action

Like Comment Share

Automated Testing shared a link. October 30, 2012

CodeBalance: Software Architecture Antipatterns : Swiss Army Knife Interface codebalance.blogspot.com "First of all, you must think that this interface will be implemented by a class and if the number of methods is excessive, there will be plenty of empty method bodies in implementor class."You make the assumption that an interface cannot provide a default implementation. That Like Comment was true 15 years ago,... Share

Unlike Comment Share

Automated Testing October 29, 2012

Automated Testing October 29, 2012

Code should not resemble Swiss Army knife :)

Does your code look like spaghetti?

Like Comment Share

Like Comment Share

Automated Testing October 28, 2012

Automated Testing updated their cover photo. October 28, 2012

http://foter.com/

Like Comment Share

Automated Testing shared a link. October 26, 2012

http://nptel.iitm.ac.in/courses/Webcoursecontents/IIT%20Kharagpur/Soft%20Engg/New_index1.html
IIT Kharagpur - NPTEL Online nptel.iitm.ac.in

Like Comment Share

Automated Testing shared a link. October 26, 2012

http://nptel.iitm.ac.in/courses.php?disciplineId=106
Like Comment Share Tag Friends NPTEL PHASE 2 - Courses nptel.iitm.ac.in Automated Testing shared a link. October 23, 2012 Like Comment Share

One more book on software architecture


Automated Testing October 23, 2012 Software Architecture: Foundations, Theory, and Practice www.amazon.com Software architecture is foundational to the development of large, practical software-intensive applications. This brand-new text covers all facets of software architecture and how it serves as the intellectual centerpiece of software development and evolution. Critically, this text focuses on su... Like Comment Share

Oct 23, 2012 10:18pm


Problems with ArchStudio and Eclipse on Ubuntu :(

Automated Testing shared a link. October 23, 2012

Definitions of software architecture http://www.sei.cmu.edu/architecture/


Software Architecture | Overview www.sei.cmu.edu Software architecture serves as the blueprint for both the system and the project developing it. Learn about the SEI's expertise in software architecture. Like Comment Share Like Comment Share

Automated Testing shared Computer Science's photo. October 13, 2012

Automated Testing October 13, 2012

I got this.

Oct 13, 2012 4:44pm

Like Comment Share

Like Comment Share

Automated Testing shared a link via Software Testing Jobs. October 12, 2012 Apply for the ARK Challenge Accelerator For Tech Startups, Application Deadline June 17 | Purdue CS: www.cs.purdue.edu The deadline approaches for applicants to The ARK Challenge Accelerator For Tech Startups New Tech Accelerator In Northwest Arkansas Offers Rare Access To Top Minds In Retail, Transportation/Logistics And Food Processing Like Comment Share

Automated Testing shared a link. October 12, 2012

Below is the link for Introduction to Software Engineering IIT Bombay Lectures in this course:39 1 - Introduction to Software Engineering (52:21) 2 - Introduction to Software Engineering (52:55) 3 - Overview of Phases (57:22) 4 - Overview ...See More
NPTEL PHASE 2 - Courses nptel.iitm.ac.in

Automated Testing October 12, 2012

Great video tutorial on software engineering http://www.youtube.com/course?list=EC8751DA481F0F0D17


Like Comment Share

Like Comment Share

Automated Testing shared a link. October 12, 2012

Automated Testing shared a link. October 12, 2012

PSP and Cleanroom Software Engineering are two software processes that deliver high-quality software
Cleanroom Software Engineering: Technology and Process www.amazon.com Cleanroom software engineering is a process for developing and certifying high-reliability software. Combining theory-based engineering technologies in project management, incremental development, software specification and design, correctness verification, and Like Comment statistical ... Share

Architecture centric software development delivers testable software


Architecture-Centric Software Project Management: A Practical Guide www.amazon.com To fully leverage the value of software architecture in enterprise development projects, you need to expressly and consciously link architecture with project management. This book shows how, drawing on powerful lessons learned at Siemens, one of the world's leading software development organizati... Like Comment Share

Automated Testing October 11, 2012

Automated Testing shared a link. October 12, 2012

Get ready for ArgoUML design critics ArgoUML Design Critics Chapter 15. The Critics Table of Contents 15.1. Introduction 15.1.1. Terminology 15.1.2. Design Issues 15.2. Uncategorized ...See More
Like Comment Share

It's sometimes very useful to evaluate software architecture by learning and observing architectures of past projects
Evaluating Software Architectures: Methods and Case Studies www.amazon.com The foundation of any software system is its architecture. Using this book, you can evaluate every aspect of architecture in advance, at remarkably low cost -- identifying improvements that can dramatically improve any system's performance, security, reliability, and maintainability. As the pract... Like Comment Share

Automated Testing October 11, 2012

Automated Testing shared a link. October 11, 2012

Screenshots from Automated testing efforts (3 photos)


Tools for automated testing of software architecture and software design

This book provides disciplined approach to software development. Once the software is built this way automated testing becomes value added tool that preserves inherent quality of PSP based software
PSP(sm): A Self-Improvement Process for Software Engineers www.amazon.com Most software-development groups have embarrassing records: By some accounts, more than half of all software projects are significantly late and over budget, and nearly a quarter of them are cancelled without ever being completed. Although developers recognize that unrealistic schedules, inade... Like Comment Share

Like Comment Share

Automated Testing shared a link. October 11, 2012

Automated Testing shared a link. October 11, 2012

Here we propose automated testing of software architecture and software design with two tools, ArchLight and ArgUML
Elevator Pitch for Testing Software Architecture and Software Design www.scribd.com Elevator Pitch for Testing Software Architecture and Software Design

Here we propose software testing checklist on how to achieve zero defects software
Zero Defects Software Checklists www.scribd.com Scribd is the world's largest social reading and publishing site.

Like Comment Share

Like Comment Share

Automated Testing 2012

Fixing Software Design Defects part 3


Fixing Software Design Defects part 3 at Belgrade, Serbia.

Like Comment Share Tag Friends

JoinedFacebook
October 11, 2012

Like Comment

Launchedin2012
Like Comment

About

Create an Ad

Create a Page

Developers

Careers

Privacy

Cookies

Terms

Help

Facebook 2013 English (US)