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

What is good code? Evaluating Code Quality (workshop)

What is good code? Evaluating Code Quality (workshop)

I've facilitated this workshop in different communities and events, from October 2017 to June 2018. Companion material (notes, resources…) including slides used in specific editions can be found @ https://github.com/dcarral/good-code.

Workshop summary:

After introducing the main topic (“What is good code?”), participants are asked to solve a simple algorithmic problem (the kata) pairing in their programming language of choice.

Once the coding session is over, it’s time for the “show & discuss” section, where volunteers show and explain their solutions to the group. Together, we discuss tradeoffs, design choices, etc.

Afterwards, concepts like software metrics and static code analysis are gently introduced before discussing even more solutions to the original problem and checking if the numbers align with the previously stated opinions.

The wide range of potential approaches (under slight time pressure, in several programming languages and with different development environments) provides an interesting context to discuss topics like:

– Software development concepts such as duplication tolerance, refactor aggressivity, layers of indirection, conditionals usage, KISS (Keep It Simple, Stupid) / DRY (Don’t Repeat Yourself), etc.

– (XP) eXtreme Programming practices: simple design, pair programming, refactoring, TDD (Test-Driven Development), etc.

Daniel Carral

October 07, 2017
Tweet

More Decks by Daniel Carral

Other Decks in Programming

Transcript

  1. Agenda ➔ Intro ➔ Craft Let’s solve the problem! ➔

    Show & discuss Which approach did you use? Why? ➔ Evaluate Opinion vs facts What do the numbers say? ➔ Retrospective
  2. How did you solve it? Why? Reminder The goal is

    not to judge our coding skills. We’re discussing how to evaluate code quality.
  3. Agenda ➔ Intro ➔ Craft Let’s solve the problem! ➔

    Show & discuss Which approach did you use? Why? ➔ Evaluate Opinion vs facts What do the numbers say? ➔ Retrospective
  4. In your opinion, what is “good code”? • “Easy to

    understand and read. Easy to test.” • “SOLID” • “Passes the squint test :)” • “Quality transcends description”
  5. Software metrics “A software metric is a standard measure of

    a degree to which a software system possesses some property.”
  6. Why measure? “You cannot control what you cannot measure.”* —

    Tom DeMarco * Apparently, he regrets having said this (thanks David!)
  7. What do the numbers say? Solution LOC Flog total Flog

    worst bit #1 Incomprehensibly concise 19 42.5 36.2 (#verse) #2 Speculatively general 63 54.8 28.5 (lambdas) #3 Concretely abstract 92 67 15.3 (#challenge) #4 Shameless green 34 25.6 19.3 (#verse)
  8. Why metrics? “Metrics are fallible but human opinion is no

    more precise. Checking metrics regularly will keep you humble and improve your code.” — Sandi Metz, Katrina Owen
  9. • Coding dojos • TDD • Refactoring • Pair programming

    • Simple design • Zen & the art of motorcycle maintenance • Clean Code • eXtreme Programming explained • 99 bottles of OOP • Beautiful code • Software metrics • LOC • Cyclomatic complexity • ABC size @dcarral dcarral.org