Pragmatic Steps to Improve Code Quality
SEPTEMBER 2019
perforce.com
Here’s What We’ll Cover Today
1
2
3
The Software Quality Challenge
Steps to Improve Code Quality
How to Improve Quality with Perforce
perforce.com
Presenter
Richard Bellairs
Product Marketing Manager
Richard has 20+ years of experience across a wide range of industries. He
held electronics and software engineering positions in the manufacturing,
defense, and test and measurement industries in the nineties and early
noughties before moving to product management and product marketing.
He now champions Perforce’s market-leading code quality management
solution.
perforce.com
The Software Quality Challenge
https://www.computerworld.com/article/3412197/top-software-failures-in-recent-history.html
Nissan’s Airbag Glitch
S A F E T Y
Wannacry
S E C U R I T Y
Amazon’s 1p Price Glitch
F I N A N C I A L
Facebook, Instagram,
and WhatsApp
B R A N D R E P U T A T I O N
perforce.com
Defining “Quality”
perforce.com
QUALITY
F U N C T I O N A L
Customer Perception
N O N - F U N C T I O N A L
Performance
S T R U C T U R A L
Profitability
Defining “Quality”
perforce.com
Sources of Defects
REQUIREMENTS
ARCHITECTURE
DESIGN
SOURCE CODE
TEST MATERIALS
DOCUMENTS
DATABASE
WEBSITES
perforce.com
QA can Become Self-defeating
https://www.blackliszt.com
R E C O M M E N D E D R E A D I N G :
Getting It Right
Keeping It Right
perforce.com
Ensure that software is:
• Safe: It can be used without causing harm.
• Secure: It can’t be hacked.
• Reliable: It functions as it should, every time.
• Testable: It can be tested at the code level.
• Maintainable: It can be maintained, even as
your codebase grows.
• Portable: It works the same in every
environment.
Achieving High Code Quality: Use a Coding Standard
perforce.com
Why use a Coding Standard?
Compliance with industry standards (e.g., ISO)
Consistent code quality — no matter who writes the code
Software security from the start
Reduced development costs and accelerated time to market
1
2
3
4
perforce.com
Achieving High Code Quality: Deploy Static Analysis
perforce.com
Types of Statically Detectable Code Defects
Defect Type Example
Static Memory Static buffer overrun
Dynamic Memory Dynamic buffer overrun
Stack-related Stack overflow
Numerical Division by zero
Resource Management Invalid access already freed memory
Pointer-related Dereferencing a NULL pointer
Concurrency Deadlock
Inappropriate code Redundant code
Other Uninitialized variables
perforce.com
Achieving High Code Quality: Define Metrics
perforce.com
Using the Helix QAC Dashboard to Track Code Metrics
VERSION
CONTROL
SYSTEM
Local analysis allows
for better quality
control early.
Server-side analysis
allows deep analysis
and provides results
in a web interface.
Other collaborators
can also access
results through
web interface.
Combine both local and server analysis
DASHBOARD
“Get it Right” “Keep it Right”
perforce.com
Team Collaboration — Management
• Reporting:
• Helps you meet project
deadlines.
• Retrospective reporting.
• Metrics:
• Understand how your project
is progressing.
• Is the software quality
improving over time?
• Is the defect injection rate
decreasing?
perforce.com
Achieving High Code Quality: Perform Manual Code Reviews
https://www.perforce.com/blog/qac/9-best-practices-code-reviews
Know what to look for.
Build and test first.
Review regularly and in small chunks.
Give constructive feedback.
Use a collaboration and tracking tool.
perforce.com
Team Collaboration — QA
• Annotations:
• Improve communication between your teams
• Identify which areas need the most attention
• Enhance peer reviews
• Code Review:
• See the control flow through your functions
• Reduce complexity and increase maintainability
• Help ensure your project is delivered on time
perforce.com
Summary
1
2
3
4
5
Quality is important
Quality is hard to define
Defects can be introduced at any stage
Too many QA activities can be bad news
Perforce tools enable a pragmatic approach to code quality
Practical Steps for Code Quality
• Use a Coding Standard
• Deploy Static Analysis
• Track Metrics
• Conduct Manual Code Reviews
Questions?

Code Quality Management Best Practices

  • 1.
    Pragmatic Steps toImprove Code Quality SEPTEMBER 2019
  • 2.
    perforce.com Here’s What We’llCover Today 1 2 3 The Software Quality Challenge Steps to Improve Code Quality How to Improve Quality with Perforce
  • 3.
    perforce.com Presenter Richard Bellairs Product MarketingManager Richard has 20+ years of experience across a wide range of industries. He held electronics and software engineering positions in the manufacturing, defense, and test and measurement industries in the nineties and early noughties before moving to product management and product marketing. He now champions Perforce’s market-leading code quality management solution.
  • 4.
    perforce.com The Software QualityChallenge https://www.computerworld.com/article/3412197/top-software-failures-in-recent-history.html Nissan’s Airbag Glitch S A F E T Y Wannacry S E C U R I T Y Amazon’s 1p Price Glitch F I N A N C I A L Facebook, Instagram, and WhatsApp B R A N D R E P U T A T I O N
  • 5.
  • 6.
    perforce.com QUALITY F U NC T I O N A L Customer Perception N O N - F U N C T I O N A L Performance S T R U C T U R A L Profitability Defining “Quality”
  • 7.
    perforce.com Sources of Defects REQUIREMENTS ARCHITECTURE DESIGN SOURCECODE TEST MATERIALS DOCUMENTS DATABASE WEBSITES
  • 8.
    perforce.com QA can BecomeSelf-defeating https://www.blackliszt.com R E C O M M E N D E D R E A D I N G : Getting It Right Keeping It Right
  • 9.
    perforce.com Ensure that softwareis: • Safe: It can be used without causing harm. • Secure: It can’t be hacked. • Reliable: It functions as it should, every time. • Testable: It can be tested at the code level. • Maintainable: It can be maintained, even as your codebase grows. • Portable: It works the same in every environment. Achieving High Code Quality: Use a Coding Standard
  • 10.
    perforce.com Why use aCoding Standard? Compliance with industry standards (e.g., ISO) Consistent code quality — no matter who writes the code Software security from the start Reduced development costs and accelerated time to market 1 2 3 4
  • 11.
    perforce.com Achieving High CodeQuality: Deploy Static Analysis
  • 12.
    perforce.com Types of StaticallyDetectable Code Defects Defect Type Example Static Memory Static buffer overrun Dynamic Memory Dynamic buffer overrun Stack-related Stack overflow Numerical Division by zero Resource Management Invalid access already freed memory Pointer-related Dereferencing a NULL pointer Concurrency Deadlock Inappropriate code Redundant code Other Uninitialized variables
  • 13.
    perforce.com Achieving High CodeQuality: Define Metrics
  • 14.
    perforce.com Using the HelixQAC Dashboard to Track Code Metrics VERSION CONTROL SYSTEM Local analysis allows for better quality control early. Server-side analysis allows deep analysis and provides results in a web interface. Other collaborators can also access results through web interface. Combine both local and server analysis DASHBOARD “Get it Right” “Keep it Right”
  • 15.
    perforce.com Team Collaboration —Management • Reporting: • Helps you meet project deadlines. • Retrospective reporting. • Metrics: • Understand how your project is progressing. • Is the software quality improving over time? • Is the defect injection rate decreasing?
  • 16.
    perforce.com Achieving High CodeQuality: Perform Manual Code Reviews https://www.perforce.com/blog/qac/9-best-practices-code-reviews Know what to look for. Build and test first. Review regularly and in small chunks. Give constructive feedback. Use a collaboration and tracking tool.
  • 17.
    perforce.com Team Collaboration —QA • Annotations: • Improve communication between your teams • Identify which areas need the most attention • Enhance peer reviews • Code Review: • See the control flow through your functions • Reduce complexity and increase maintainability • Help ensure your project is delivered on time
  • 18.
    perforce.com Summary 1 2 3 4 5 Quality is important Qualityis hard to define Defects can be introduced at any stage Too many QA activities can be bad news Perforce tools enable a pragmatic approach to code quality Practical Steps for Code Quality • Use a Coding Standard • Deploy Static Analysis • Track Metrics • Conduct Manual Code Reviews
  • 19.