Hacker News new | ask | show | jobs
by jbrains 4429 days ago
I think of it the other way: if it's easy to write code that "understands" your code, then it's probably easy to understand your code, because you can encode (ha!) your understanding precisely enough for a computer to execute it and accurately enough to pass tests.

I don't quite buy the contrapositive, though: I easily understand small functions that touch well-named global variables, as long as it touches maybe 1 or 2 of them, but we wouldn't call such a function particularly "testable". At some point, poor testability and difficulty in understanding correlate, but we can easily exhibit entire classes (ha again!) of easy-to-understand-but-difficult-to-test code.

If we had a catalog mapping test/testing problems to design smells, perhaps we'd find it easier to argue our position more convincingly. A bunch of us keep meaning to write that catalog, but I haven't seen it yet. :)