loading...

Discussion on: Code readability metrics?

Collapse
josephtaylor profile image
J. Taylor O'Connor

Static analysis tools like Sonar can do some of this already, definitely the complexity measures Austin mentioned. Some other things that come to mind are:

  • class size in lines of code
  • levels of indentation (i like to keep it under 2)
  • number of parameters to a function
  • number of methods on an interface
  • number of break/continue statements inside loops
  • abbreviations in names (variables, functions, and types)

everyone working on the same pieces of code should definitely have a common formatting that’s performed on every file. Variations from the standard format could be measured.

Collapse
stereobooster profile image
stereobooster Author

I don't think that size (LOC or number of something) is readability metric. See my answer here dev.to/stereobooster/comment/m56f

Collapse
josephtaylor profile image
J. Taylor O'Connor

There’s the idea that you can follow a simple set of (arguably measurable by code) rules and you’ll end up with much more readable code. This topic always makes me think of this talk—following small rules can add up to big readability improvements.