Title: Defect Tracking, Coding Standards, Reviews
1Defect Tracking, Coding Standards, Reviews
2Agenda
- Review
- Defect Tracking
- Coding Standards
- Code Reviews
3Measurement for Improvement
You cant control what you cant measure. -
Tom Demarco
In God we trust, all others send data - Edward
Deming
How do we know what to fix?
If you dont know where you are Going, any map
will do. If you dont know where you are, A map
wont help. -- Watts Humphreys
4Defect Tracking
Defect Log Date Phase (Analysis, Design,
Coding, Test) Type Category Description Ig
nore Cascading Failures
5Defect Categories
- 10 Documentation problem
- 20 Syntax
- 30 Build
- 40 Assignment
- 50 Interface
- 60 Error Handling
- 70 Data
- 80 Function
- 90 System
- 100 Environment
6Aggregated Defect Log
Lab 3, Sig Manager Deluxe 10 Incorrect
Comments Code Standard Violations
20 Missing Semicolons Misspelled
variable names 30 Make file syntax
7Code and Customers
If we want to conform to customer expectations,
then who are the customers for our source code????
8Code Standards
- We write code for
- Compiler
- Ourselves
- Others (Maintainers and Team Members)
9Bad Code
X X XX XXX A ST(A) X X LF(X1,X)
XXX X X I(X1,X)
10Better Code
Balance Balance LastPayment MonthlyTotal
NewPurchase
SalesTax(NewPurchase) Balance Balance
LateFee(CustomerID, Balance)
MonthlyTotal Balance Balance
Interest(CustomerID,Balance)
11Code Standards Guide
1. Adhere to original style
2. Principle of Least Astonishment
3. Do it right the first time
4. Document Deviations
5. Indent nested code
6. Break Long Lines
7. Include Whitespace
8. Avoid Hard Tabs
9. Use Good Meaningful Names
See Sun Web site and EJS
12Code Reviews
- Formal or Informal
- Find Errors in Style and Logic
- Research -gt 50-90 of code defects
- Roles
- Reader
- Moderator
- Recorder
- Use Checklist
- Critique Code, NOT Coder
- Preparation
13Checklist (Classes)
- Is the class name appropriate?
- Could it be abstract?
- Does the header describe its purpose?
- Does the header reference reqmnts/ design?
- Does the header identify the package or
component that the class is a part of? - Is it as private as it can be?
- Should it be final, singleton or other pattern?
- Have documentation standards been applied?
14Checklist (Attributes)
- Is the attribute necessary?
- Could it be static?
- Should it be final?
- Are naming conventions followed?
- Proper access control (pub,prot,priv)
- Are attributes independent?
- Is there a comprehensive initialization strategy?
15Checklist (Constructors)
- Is constructor necessary (vs. factory)?
- Does it initialize all the attributes?
- Is it as private as possible?
- Does it execute the inherited constructors where
necessary?
16Checklist (Method Header)
- Is the method name appropriate?
- Is it as private as possible?
- Should it be static?
- Should it be final?
- Does header describe purpose?
- Does header ref reqmnts/design?
- Does it state pre/post conditions?
- Does it comply with doc standards?
- Are parameter types restricted?
17Checklist (Method Body)
- Is algorithm consistent with design?
- Does code comply with precondition?
- Does code produce all postcondition?
- Does every loop terminate?
- Compliance with notation standards?
- Braces Balanced?
- Illegal parameter handling?
- Return type correct?
- Comments?
- Side Effects?
- Layout/Style?
18Outputs
- Code Review Report
- Members (Who was there)
- Issues (NOT SOLUTIONS!!)
- Priorities (How important is each issue)
- Action Plan (What you are doing about this)
- Signatures (Admit you were there)
19Automated Code Reviews
Checkstyle PMD
20Remember
- Write your code for somebody else who doesnt
understand it, because by the time you come back
to it, that somebody else will be you.
21Automated Code Reviews
- Checkstyle
- PMD
- Jalopy
- Eclipse
22Coming Up
Java 1.5 New Features
Java Streams/Serialization
Java Threads/Network Programming