Code review
Optimization
- Optimal Use of String Literals
- Use string buffer for concatenation operations instead of strign literal
- Avoid Variable Instantiation Inside Loops
- Optimize Loop Exit Condition
- sample:
Wrong Block
While(Loop Exit Condition Through Method Call) {
Loop Processing
}
Right Block
Loop Exit Condition Variable = Loop Exit Condition Through Method Call
While (Loop Exit Condition Variable) {
Loop Processing
}
- Conduct Read/Write Operations in Blocks
- Perform Lazy Instantiation of Variables
- Use Synchronization Carefully
- Optimize Object Allocation and De-allocation
- Control Cyclomatic Complexity
Code Maintainablility
- Adhere to Coding Standards
Every development assignment should have a set of coding standards, which form the program code template. Adherence to coding standards will help:
- Achieve consistency in work products
- Provide quality deliverables, because coding standards are created by experts to capture best practices
- Make the program easy to understand and maintain it by improving code readability
- Make reviews and sign-offs less time-consuming
- Reduce rework, as it directly impacts schedule and cost
- Use Consants
- Avoid the Use of Deprecated Methods
UI Standards
- Avoid Hard Coding of String Literals
- Avoid Hard Coding of UI Component Dimensions
- Use Threading Effectively
Exception Handing
- Ensure Database Resources are Released
- Put Loop Inside Exception Handling Blocks
Wrong Block
Loop Start
Code Block
Exception Handing {
}
Loop End
Right Block
Loop Start
Code Block
Loop End
Exception Handing {
}
- Log Exceptions with Debugging Infromation
Database Resources Handing
- Open connection Just-in-time
- Optimaize the Frequency of Database Access
- Perform Database Operations in Bathes
- Optimazie Use of Database Tables Partitioning
- Optimazie Use of Database Table Indexing
- Optimazie Use of Database Table Views
- Optimazie Use of Database Stored Procedures
Metrics Relevant to Code Review
- Defect Density
Defect Density = Number of Defects Found / Total Lines of Code
- Cost of Quality
Cost of Qulity(CoQ) = [(Appraisal Cost + Preventive Cost + Failure Cost) / Total Project Effort] * 100%
Appraisal Cost = Hours spent on reviews and testing
Preventive Cost = Hours spent on quality audits, defect prevention, metrics data collection, and analysis
Failure Cost = Hours spent on fix and rework
Total Project Effort = Total hours spent by the project(development, project management, and quality activities)
- Cost of Rework
Cost of Rework(CoR) = (Failure Cost / Total Project Effort) * 100 %
- Phase Containment Effectiveness
Phase Containment Effectiveness = (Number of Defects Contained / Number of Defects Injected) * 100%
- Defect Orgin
Defect Origjin = Number of Defects Injected / Total LOC
LOC: the number of defects injected per Line of Codes
- Defect Injection Rete
Defect Rate = Number of Defects Injected /Total Development Effort
Number of Defects Injected = Number of defects injected per stage found prior to and after delivery or release to onshore or client in a requirement of release.
Total Development Effort = Sum of development effort expended per stage of work scope for the requrement or release. This excludes management, training, and defect prevention hours.
- Peer Review Effectivess
Peer Review Effectivess = [Number of Defects Found/ (Number of Defects Found + Number of Defects Missed)] * 100%
Number of Defects Found = Number of defects found per stage
Number of Defects Missed = Total number of peer review defects from current and preceding stages that were detected in subsequent stages
- Peer Review Efficiency
Peer Review Efficiency = Number of Defects Found / Total Time Spent on Peer Reviews
Number of Defects Found = Number of defects found per stage
Total Time Spent on Peer Reviews = Hours spent on review preparation time, review time, and documenting review points per stage
- Peer Review Compliance
Peer Review Compliance = (Number of Peer Reviews Conducted / Number of Peer Reviews Planned)*100%
- Delevered Defect Density
Delevered Defect Density = Number of Defect Found After Delivery/ Total Lines of Code