2 ms·
I don't like long functions because they're harder to write unit tests for. I make too many mistakes, and I need the unit tests to verify the code and bring do
by rectang 6y ago
I don't like long functions because they're harder to write unit tests for. I make too many mistakes, and I need the unit tests to verify the code and bring down my error rate.
- arcturus17 6y agoI agree with this... If a part of a function is a hotspot of unavoidable complexity then it's good to split it out and test it. But then some people will say that you're testing the internals of the caller and that you shouldn't do that. If we follow that logic to the absurd, there should only be one test for the entire application, one for main(), or whatever your entry point is. I've never seen an answer to this problem coded as an intelligible, easy-to-follow guideline. Empirically and intuitively I think my "hotspot" approach kinda works in maximizing reliability.