Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Beyond Clean Code & Code Quality

Beyond Clean Code & Code Quality

Beyond Clean Code & Code Quality slide deck from my talk at CodeEurope, December 5th in Krakow

Papapetrou Patroklos

December 05, 2017
Tweet

More Decks by Papapetrou Patroklos

Other Decks in Programming

Transcript

  1. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Ego Boost • I’m from Thessaloniki, Greece • The city of “White” Tower… • …which is not white at all!
  2. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Ego Boost • I’m from Thessaloniki, Greece • The city of “Frappe” … • …a special coffee that you can find (almost) ONLY in Greece
  3. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Ego Boost • I’m from Thessaloniki, Greece • The city of “Frappe” … • …a special coffee that you can find (almost) ONLY in Greece
  4. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Ego Boost • I’m from Thessaloniki, Greece • The city of “Mpougatsa” … • …a pie you can fill with (almost) everything
  5. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Ego Boost(seriously now) • Principal Software Engineer @ • Co-author of “SonarQube in Action” book • Software Quality evangelist - Software Gardener • Local Tech Community Leader • Father of two
  6. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden What is this talk NOT about • Quality metrics • Code reviews • Specific tool(s) • Specific programming language(s) • Explaining technical debt
  7. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden I had a dream… ...that one day code quality management will be as much as important and essential as is today source code management
  8. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden How it all starts?
  9. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden We measured the code quality!
  10. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden We measured the code quality! Now what? Duplications Density Code Coverage Cyclomatic Complexity Cognitive Complexity Branch Coverage Line Coverage Quality Flows Incoming coupling Outgoing coupling Performance Issues Style / Format inconsistencies Lack of Documentation Security vulnerabilities
  11. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden We measured the code quality! Now what?
  12. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Focus on 3 categories •Security •Maintainability •Reliability
  13. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Sitting on the Technical Debt smell bomb
  14. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Technical Debt Definition If the debt grows large enough, eventually the company will spend more on servicing its debt than it invests in increasing the value of its other assets Steve McConell - Author of Code Complete
  15. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden So many questions • How do we get management buy-in? • How Technical Debt affects our team(s)? • What about legacy code?
  16. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden So many questions • Product team pushes for new features. No time for refactoring. What should we do? • Is there a silver bullet to tackle code quality? • What to fix / improve first?
  17. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden How to convince my “superior” • Wear different hats for technical and non-technical people • Speak the management language • Provide a single number in terms of currency or time to market • Don’t ask for permission • Do a PoC
  18. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden How to convince my “superior”
  19. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden The human factor of Technical Debt Frustrated developers
  20. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden The human factor of Technical Debt Low morale - People leave
  21. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden The human factor of Technical Debt Hard to get new people in - business collapses
  22. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Should we improve quality of legacy code? • Yes
  23. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Should we improve quality of legacy code? • Yes No
  24. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Should we improve quality of legacy code? • Yes No It depends • Useless to refactor code that is never changing • Keep an eye on code churn • Avoid refactoring for the shake of refactoring
  25. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ?
  26. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ? • YES!
  27. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ? • YES! - Great then just stop adding crappy code
  28. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ?
  29. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ? • No!
  30. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ? • No! - Then you are in deep shit
  31. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Product team pushes for new features • Do you work for a startup or a Greenfield project ? • No! - Then you are in deep shit • Try to keep a balance • Pretend you are in a Greenfield project
  32. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden What’s the best way to improve code Quality? • No silver bullet • Patience • Consistency • Professionalism • Technical Excellence
  33. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Strategies to tackle technical debt Hold your ground
  34. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Strategies to tackle technical debt Move the goal posts
  35. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Strategies to tackle technical debt The Boy Scout approach
  36. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Strategies to tackle technical debt Code Quality Time - Fix the worst first
  37. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Strategies to tackle technical debt Re-architect / Re-engineer
  38. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Bonus slide - Automation • Step #0 - Define a common set of objective quality rules, agreed by all team members • Step #1 - Automatically check your code locally (Pre-commit checks) • Step #2 - Integrate with your favourite CI engine • Step #3 - Integrate with your favourite code review tool (Post-commit checks) • Step #4 - Reject PRs if quality threshold is hit
  39. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Code review made simple Quality Issues found / reported Unit Tests Coverage Integration Tests Coverage
  40. Krakow, December 5th 2017, Beyond Clean Code & Code Quality

    by @softwaregarden Take - aways • The fight against technical debt starts once you understand the metrics - it doesn’t end that time • Poor code quality has side-effects to the team’s psychology • Be patient and don’t give up • One size doesn’t fit all. Experiment. Find your way