styleguides
styleguides copied to clipboard
Misleading phrasing: changing code to make it testable
Hi all,
I stumbled across this phrasing:
"Don't change the productive code to make the code testable"
The intended meaning is clarified by the example, but the heading is really misleading. There is nothing wrong with changing productive code in order to make it testable. Mind that "testable code" is not "test code". Testable code is always a major design goal and we often refactor towards this goal. The issue is when productive code contains test code. I would suggest another phrasing, for example:
- "Don't let test code invade producitve code" or
- "Productive code must not contain test code"
Best, Jonathan
Good point, I think we should distinguish valid use cases too, application-level test code is OK. Have had a go at some wording in a PR.