←back to thread

Unit tests as documentation

(www.thecoder.cafe)
94 points thunderbong | 1 comments | | HN request time: 0s | source
Show context
Etheryte ◴[] No.41872206[source]
This is functionally not different from saying your code is your documentation. If it builds, then it's valid, etc. In other words, nonsense. Code, tests and documentation each serve a useful purpose and crucially they each serve a purpose that's distinct from the other ones, but supports them. Code is there to do the thing, tests are there to make sure the thing is done correctly, documentation is for other humans to understand what the thing is and how it's done.
replies(1): >>41872373 #
wubrr ◴[] No.41872373[source]
Code as documentation is not nonsense at all. I do think high quality documentation should exist on it's own, but cleanly written and organized, well-commented code that is easy to read and understand is extremely valuable for many reasons. It IS a huge part of the documentation for the technical people that have to maintain the code and/or use it in advanced/specialized ways.
replies(1): >>41872984 #
Etheryte ◴[] No.41872984[source]
Yes, except this is not what people talk about when they say code is the documentation. What's meant in that context is no documentation and only code, with the idea that you can always read the code if you need to figure something out. Which, of course, is nonsense.
replies(1): >>41873475 #
1. wubrr ◴[] No.41873475[source]
Nah, that's your own (incorrect) interpretation, the first result of googling 'code as documentation' [0], starts off with:

> Almost immediately I feel the need to rebut a common misunderstanding. Such a principle is not saying that code is the only documentation.

[0] https://martinfowler.com/bliki/CodeAsDocumentation.html