DEV Community

Discussion on: What's worse: Stale documentation or no documentation?

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

I also find tests necessary but tests and doc cover two different things.

Documentation is to provide ease to use for developers while tests "explain" behaviour. You also can add documentation inside your tests and point to the issue or whatever.

On the other hand, there are ways (linter, CR) to ensure both that people add doc plus that they update the doc along changes in functions/methods.

If we're talking about a different kind of documentation (wiki) then yes, this -almost- never ends well.

Collapse
 
mcsee profile image
Maxi Contieri

In My code reviews, I usually remove Doc documentation since they bring no value and are in danger of obsolence. No documentation is better than useless documentation

see

and

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

So instead enforcing the documentation and keeping it up to date you prefer to remove it... What can go wrong.

It may not bring "value" but it speeds up future developments and maintenance for sure 🤷🏻‍♀️

Thread Thread
 
mcsee profile image
Maxi Contieri

ussually I just don't remove it. I write a self documenting test instead.
Then I remove th comment before it gets obsolete

Maintenance is granted as long as you have automated tests.
You can add a bunch of documentation and yet bring zero maintenance value since developers don't read documentation. But if they break a test, they will have inmediate feedback

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

Well, it depends on the environment/language till certain point but as I already said, documentation can be enforced through lints or any other tool and you'll get feedback for sure.
check this as example.

On the other side, tests should not don't apply to every single function you have. Tests are meant to ensure behaviour (public interface) while documentation in functions is meant to add information to the implementation details.

That's the reason I said both are not exclusive neither they are replaceable between each other.

Thread Thread
 
mcsee profile image
Maxi Contieri

I see your point in your article.
If it keeps updated automatically I am ok with it.

Implementation details are accidental and can change as long as no external contract is broken.
documentation should be the exception for a very small use cases, IMHO

Collapse
 
qm3ster profile image
Mihail Malo

That's where doctests come in.

Thread Thread
 
mcsee profile image
Maxi Contieri

What is their added value?

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

What do you understand as "value"?

Thread Thread
 
mcsee profile image
Maxi Contieri

The add value that doctests add

If I see a point I will start to use them instead of removing them

Thread Thread
 
qm3ster profile image
Mihail Malo

Usage examples that never go stale because they are tests that run.