3 ms·
This made me think of two tangentially related things about code quality and reading which are each 10 years old! Peter Seibel repeatedly tried to start "code
by abeppu 2y ago
This made me think of two tangentially related things about code quality and reading which are each 10 years old!
Peter Seibel repeatedly tried to start "code reading groups", but found that they didn't quite work, because while everyone agreed that there was much to be learned from code bases, and that many advised "reading" code, most real code doesn't support "reading" so much as "decoding" or perhaps interactively exploring.
https://gigamonkeys.com/code-reading/ https://gigamonkeys.com/code-reading/
Robert Heaton had a fun post about code reviewing without being able to actually read the specifics of the code. With only a blurry view of the structure of code, one can get a sense of its likely virtues and opportunities for improvement.
https://robertheaton.com/2014/06/20/code-review-without-your-eyes/ https://robertheaton.com/2014/06/20/code-review-without-your...
Kind of in the spirit of both, I love code where you don't _have_ to read most of it because:
- class names, generic parameters, etc, make it clear what classes represent
- method names and signatures make it clear how they're to be used; there are no surprises or gotchas in the specifics of the implementation that foist cognitive complexity onto callers, etc
- the right amount / granularity of structure exists, such that when you do need to read something, the section is moderately sized; there's not some enormous, entangled method that's actually doing 5 things at once. Modularity limits the scope of reading.
But also, when you do need to understand implementation specifics, good code acknowledges that reading is likely not "enough"; good code gives straight-forward on-ramps to interact and experiment with it. It doesn't force you to hunt for a bunch of environmental variables, configurations that are examined by an IoC layer, or magically materialize a file containing a specific serialization of a well-formed record just to invoke.