twelve ways to make code suck less
play

Twelve Ways to Make Code Suck Less Venkat Subramaniam - PowerPoint PPT Presentation

Twelve Ways to Make Code Suck Less Venkat Subramaniam venkats@agiledeveloper.com @venkat_s Why should we care about code quality? We cant be agile if our code sucks Lowering quality lengthens development time.First Law of


  1. Twelve Ways to Make Code Suck Less Venkat Subramaniam venkats@agiledeveloper.com @venkat_s

  2. Why should we care about code quality?

  3. We can’t be agile if our code sucks

  4. “Lowering quality lengthens development time.”—First Law of Programming. http://c2.com/cgi/wiki?FirstLawOfProgramming

  5. What’s Quality Code?

  6. The quality of code is inversely proportional to the effort it takes to understand it. http://blog.agiledeveloper.com/2010/05/thoughts-through-tweets_15.html

  7. Twelve ways We can Help

  8. 12. Schedule Time to Lower Technical Debt

  9. What’s Technical Debt? Ward Cunningham http://c2.com/cgi/wiki?WardExplainsDebtMetaphor

  10. Example of Technical Debts

  11. Low quality is not technical debt

  12. What Causes Technical Debt?

  13. Not “All or Nothing”

  14. Schedule Time

  15. Development Paying Technical Debt Planning… Vacation/sickness Meetings … Slack time

  16. Linda Rising

  17. Development Paying Technical Debt Planning… Vacation/sickness Meetings … Slack time

  18. 11. Favor High Cohesion

  19. Narrow, focused, does only one thing well

  20. Why?

  21. Think about frequency of change

  22. high cohesion == low cyclomatic complexity

  23. 10. Favor Loose Coupling

  24. Tight coupling make code hard to extend hard to test

  25. Lower coupling Loose vs. tight coupling Eliminate where possible

  26. Excessive Non deterministic Mocking Dependency to Test This

  27. Non deterministic Dependency Light No Mocking Mocking to Test to Test This This

  28. 9. Program with Intention

  29. http://stackoverflow.com/questions/184618/what-is-the-best- comment-in-source-code-you-have-ever-encountered

  30. Beck’s Rule for Simple Design http://martinfowler.com/bliki/BeckDesignRules.html

  31. Programming Deliberately • When you write test before writing code…

  32. 8. Avoid Primitive Obsession

  33. It’s code like this that prematurely turns programmers into managers

  34. http://blog.agiledeveloper.com/2015/08/the-functional-style.html

  35. 7. Prefer Clear Code over Clever Code

  36. 10% of the time, we write ugly code for performance reasons, the other 90% of the time, we write ugly code to be consistent. http://blog.agiledeveloper.com/2010/05/thoughts-through-tweets_15.html

  37. Those who sacrifice quality to get performance may end up getting neither. http://blog.agiledeveloper.com/2010/05/thoughts-through-tweets_15.html

  38. “There are two ways of constructing a “There are two ways of constructing a software design. One way is to make it software design. One way is to make it so simple that there are obviously no so simple that there are obviously no deficiencies and the other is to make it deficiencies and the other is to make it so complicated that there are no so complicated that there are no obvious deficiencies”— Tony Hoare obvious deficiencies”— Tony Hoare

  39. 6. Apply Zinsser's Principle on Writing

  40. Simplicity Clarity Brevity Humanity

  41. 5. Comment Why, not What

  42. Don’t comment to cover up bad code

  43. Write Expressive Self-Documenting Code

  44. A good code is like a good joke Writing comments is like explaining a joke http://blog.agiledeveloper.com/2006/01/comments-on- comments.html

  45. order(3) 3 cups?… order(3) // large coffee order(CoffeeSize.LARGE)

  46. https://media.pragprog.com/titles/pad/PAD-pulloutcard.pdf

  47. 4. Avoid Long Methods—Apply SLAP

  48. Perils of Long Methods

  49. How long is long?

  50. Turns out long is not about length of code, but levels of abstraction

  51. 3. Give Good Meaningful Names

  52. Variable Names Represent Abstractions

  53. 2. Do Tactical Code Reviews

  54. Peer reviews catch 60% of defects. Perspective-based reviews catch 35% more defects than nondirected reviews. Peer reviews complement testing. Technical and social activity. https://www.cs.umd.edu/projects/SoftEng/ESEG/papers/82.78.pdf

  55. Facilitating Tactical Code Reviews

  56. 1. Reduce State & State Mutation

  57. Twelve Ways to Make Code Suck Less

  58. 12. Schedule Time to Lower Technical Debt 11. Favor High Cohesion 10. Favor Loose Coupling 9. Program with Intention 8. Avoid Primitive Obsession 7. Prefer Clear Code over Clever Code 6. Apply Zinsser's Principle on Writing 5. Comment Why, not What 4. Avoid Long Methods—Apply SLAP 3. Give Good Meaningful Names 2. Do Tactical Code Reviews 1. Reduce State & State Mutation

  59. http://agiledeveloper.com/downloads.html

  60. Thank you http://agiledeveloper.com/downloads.html venkats@agiledeveloper.com @venkat_s

Recommend


More recommend