styleguides icon indicating copy to clipboard operation
styleguides copied to clipboard

Misleading phrasing: changing code to make it testable

Open jdgx opened this issue 4 years ago • 1 comments

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

jdgx avatar Oct 14 '21 07:10 jdgx

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.

pokrakam avatar Oct 16 '21 15:10 pokrakam