6 ms·
"[I]f your tests are ugly, its a sign your code is ugly" is a bit tautological, and highly subjective besides. I consider the 50-line function to be "less ugly
by sidlls 5y ago
"[I]f your tests are ugly, its a sign your code is ugly" is a bit tautological, and highly subjective besides.
I consider the 50-line function to be "less ugly" than the same function butchered for "testability" into a bog of poor abstractions and single-use smaller functions.
- blacktriangle 5y agoI agree some TDD advocates are way to big on loc as a metric for testability. Loc is pretty much irrelevant for both testability and readability.
- disease 5y agoFor me at least, TDD has driven me to look for more functional solutions to problems. It's hard to come up with a more testable piece of code than a pure function that spits out the same output every time for a given input. Unfortunately this approach tends to be less effective in languages that do not have good support for functional ideas like Java and C#.