DEV Community

Discussion on: Is testability a reason to change your design?

Collapse
 
bosepchuk profile image
Blaine Osepchuk

Uncle Bob said (I'm paraphrasing) that if he had to choose between having a complete test suite and the code it tested, he'd prefer the tests because he could use the tests to recreate the implementation but he can't do much with a pile of code without tests.

I agree with the point he was trying to make.

Q: If you get hit by a bit tomorrow what would the next guy or gal who has to maintain your code want to see? Clean code following SOLID principles with "good" tests? That would be my hope if I was that next guy.

The longer I do this (programming), the less patience I have for code without tests.

Thread Thread
 
codemouse92 profile image
Jason C. McDonald

The "bus factor" is my motive for leaving extensive intent inline comments and external documentation. Tests shouldn't have to be used to recreate intent, which is the ingredient from which we recreate code. In fact, I'd even say that having to recreate intent from tests is only slightly less soul-sucking than recreating from raw code. Therefore, I'd say it's a terrible motive to writing tests.

That said, yes, tests are virtually always something you should have as part of your code base.