Clean Code and How to Achieve Zero Defects Jason Jolley Director, Application Development Micro Strategies, Inc.
Achieving Zero Defects Is it possible?
Achieving Zero Defects Why is this so important?
What is Clean Code? Clean code is simple and direct. Clean code reads like well-written prose. -Grady Booch
Clean Code Basics Clear & Consistent Naming Avoid using Comments Keep functions less than 10 lines
Four Simple Rules Pass All Tests Clear, Expressive, & Consistent Duplicates No Behavior Or Configuration Minimal Methods, Classes, & Modules -Kent Beck
Test Driven Development Red Green Refactor
Test Driven Development Red Green Refactor
Test Driven Development You should have > 80% Coverage. If you don’t have at least 80%, try harder.
Code of Conduct 1.Only Ship Quality Software 2.Stable Productivity 3.Inexpensive Adaptability 4.Continuous Improvement 5.Fearless Competence 6.Extreme Quality
Code of Conduct 7.QA Will Find Nothing! 8.Automation 9.Honest Estimates 10.Say No When We Can't Commit 11.Continuous Aggressive Learning 12.Mentor Each Other 13.Not Be A Knowledge Silo
Accountability & Code Analysis Code Analysis can detect problem areas Continuous Integration and Code Analysis together provide an automated process to gain code metrics. Facilitates peer review
Project Code Analysis
Cyclomatic Complexity The count of the number of linearly independent paths through the source code M = E − N + 2P E=the number of edges of the graph N=the number of nodes of the graph P=the number of connected components *Source: Wikipedia
Cyclomatic Complexity AKA: The canary in the coal mine Any function with a complexity greater than 8 should be re-evaluated.
SOLID Principles The S ingle Responsibility Principle A class should have one, and only one, reason to change. The O pen Closed Principle You should be able to extend a classes behavior, without modifying it. The L iskov Substitution Principle Derived classes must be substitutable for their base classes. The I nterface Segregation Principle Make fine grained interfaces that are client specific. The D ependency Inversion Principle Depend on abstractions, not on concretions.
Customizing Alfresco ActionExecutor classes Web Scripts Task Listeners Custom Service Classes
Customizing Alfresco ActionExecutor classes Web Scripts Task Listeners Custom Service Classes
Maintain Metrics Estimates to Actuals Coverage Complexity Violations Bugs Logged
The Big Picture Evangelize An Ethos of Craftsmanship and Accountability
In Summary The only way to go fast, is to go well. -Uncle Bob Martin
Resources Related Blog Posts