2. OVERVIEW
▪ Clean code principles
▪ Code Review
▪ TDD
▪ Refactoring
▪ SCM, SCA, CI and other abbreviations
▪ Being a good programmer
3. WHAT DO YOU CONSIDER CLEAN CODE?
▪ Readable
▪ Error free
▪ Elegant
▪ Testable
▪ Efficient
4. MEANINGFUL NAMES
▪ For class, method or variable, name should suggest
▪ Why is exists
▪ What it does
▪ How it is used
▪ Don’t include type info
▪ Why?
▪ Be honest
▪ No side effects
▪ So what about comments?
5. WHAT MAKES A GOOD FUNCTION?
▪ Short
▪ Efficient
▪ Does one thing
▪ Reusable
▪ Few variables
▪ No side effects
6. CODE REVIEW - MOTIVATION
Definition: The analysis of source code in order to find defects
▪Early bug detection
▪Knowledge sharing
▪Code improvements
▪Social communication
▪Understanding
* Expectations vs. Actual
7. CODE REVIEW – PRACTICAL GUIDE
▪ Let the tools work for you:
▪ Formatter
▪ Lint
▪ Find problems, not solutions
▪ As a reviewer – be nice
▪ As a reviewed – leave you ego in the drawer
▪ Don’t skip it (no valid excuses)
9. REFACTORING
▪ Why ?
▪ Cost of owning a mess*:
▪ Don’t make it to “The grand re-design”*
▪ Code that smells
▪ Duplicate code
▪ Longs methods
▪ Deep nesting
▪ Too many variables in a method
* Rober C Marting – “Clean Code..”
10. REFACTORING TIPS
▪ Valid changes – let your IDE work for you
▪ Renaming
▪ Extract variable
▪ Extract method
▪ Move
▪ Introduce parameter
▪ Unit tests coverage is your friend
11. SCM – SOFTWARE CONFIGURATION
MANAGEMENT
▪ Track and control changes in software
▪ Confidence in change - Can always go back
▪ When to start using it?
▪ Git – free and open source
▪ Github – host
▪ Other free/commercial tools – CVS, SVN, ClearCase
12. SCA – STATIC CODE ANALYSIS
▪ Analyzing code without executing it
▪ Common Errors detectible by SCA
▪ Buffers and arrays underflows overflows
▪ Resource leaks
▪ Potential null references
▪ Lack of initialization
▪ Common tools: Sonar, FindBugs, Checkstyle
13. CI – CONTINUOUS INTEGRATION
▪ is the practice of merging all developer working copies with a
shared mainline several times a day
▪ Considered an XP (extreme programming) habit
▪ Possibly dozens of “commits” every day
▪ Prevent “Integration Hell”
▪ Automated unit tests in build server
▪ Next step: CD – Continuous Delivery
14. BEING A GOOD PROGRAMMER
▪ Respect your ancestors
▪ The Netscape rewrite story
▪ Acknowledge your successors
▪ Meaningful names, Comments
▪ Avoid code duplications
▪ “Leave the camp ground cleaner than you found it”
15. RECOMMENDED READINGS
▪ "Clean Code: A Handbook of Agile Software Craftsmanship“ by Robert
C. Martins
▪ “The Pragmatic Programmer” by Dave Thomas and Andy Hunt
▪ Effective <fill in your language>