This is a misconception of many coders, surprisingly even professionals that you can somehow replace documentation with good naming.
Sorry but … nope !
Code can never come even close as a light year to conveying even half the information that documentation can. That’s is just the reality of it.
As a matter of fact you can understand code fine even with the worst name in the history of coding if it comes with good documentation.
You will never be able to understand any quite of large coding project just by reading the code unless you are willing to close yourself in a room and not get out for months if not years. Documentation will help you understand it in days at most weeks.
No programming language was ever made to represent abstract concepts.A programming language may have “language” in its description but as languages go is extremely limited one. Actually programming languages really suck at it.
Programming languages not only are extremely limited in describing the what and the how, but they are completely incapable of explaining the why which what makes comments mandatory to every single line of code. But because having a ton of comments is not pretty, you fall back tooooo…yeap… documentation.
Sure if you write a simple main() you don’t need it, if you make a simple function you dont need but in the real word 99% of the time you will need it. Actually you need it so much that coding nowdays has far more mediums of expressions than programming in form of wikis, references, tutorials, QAs , forums, live chat and much more. The only form of expression for programming is the programming language, the end.
The problem becomes bigger with legacy code that tends to be nothing more than a collection of badly designed patches. Good designs need time, coders rarely have the time to do that because bosses or they want features. Code grows bigger and bigger and more and more ugly. Good naming provides zero help because everything is spaggetified and documentation is your only salvation because a rewrite aint gonna happen any time soon.
So yes please do use good names, totally agree, but no definitely not do it to avoid writing documentation and by documentation I dont mean 2 lines comments. The bigger the project the bigger its reliance on good documentation.
And no you cannot use unit testing for replacing documentation either. No way around it. Either you document or your code sucks big time because people wont even bother reading it. Even with the best naming in the world. Plus if you start reading your own code years after you probably gonna ask yourself what the hell you were thinking when you were writing the code.