Today I got into a discussion with a colleague on how to document code within a large web project. My preferred method is to trust my code to be self-explaining on what it does and rely on JSDocs or block comments for why it does its thing. Hacky or weird lines get the occasional line comment.
I dislike documenting my code in other places (like wikis or tickets), because that gets outdated and forgotten pretty quickly.
How do you handle that?
Do you trust your code to be self-explaining? Do you use JSDocs/PHPDocs/etc? Do you comment extensively? Or maintain a huge wiki?
What works out for you and why?
Top comments (3)
I document extensively with JSDoc and Visual Studio's default C# document style. But I don't (yet) write anything to an external wiki.
I find it useful to describe classes' and methods' intended role in the larger business context. I think that sometimes carries meaning that the code alone cannot.
I'm all for self explaining code and long, declarative function names. However I see them more fitting for describing "what" the code does and rather limited for "why". Whenever I try to adopt third party code I find it much more challenging to understand the architecture than the methods.
I just included wikis for the sake of completeness. I had to document in confluence in the past and found it very problematic. It kept being forgotten, out of date and cumbersome. No recommendation from me.
I find that both doc-blocks in your code and wiki-style prose documentation are very useful, and for larger projects, both are absolutely needed.
I completely agree that wikis kept in another repository or in an external system are extremely prone to getting out of sync, which is why I prefer to keep wikis as Markdown inside the project repo itself. Even putting a fair amount of structured prose in a README is a great idea, too, if you don't need a full multi-page wiki. And as a bonus, you get versioned documentation for free simply by tagging your releases!
Here's my pro/con list for both doc-blocks and wikis:
Doc-blocks
Pros
Cons
Prose/Wikis
Pros
Cons
As the maintainer of a documentation tool, Orchid, I've posted here several times related to documentation. Check them out for more of my thoughts on documentation, and try Orchid as a solution to the normal cons of a wiki!
5 Tips for Writing Good Documentation
Casey Brooks ・ Nov 5 '18 ・ 1 min read
How To Document A Kotlin Project
Casey Brooks ・ Feb 18 ・ 14 min read
What makes maintaining documentation difficult?
Casey Brooks ・ May 8 '18 ・ 1 min read
JavaEden / Orchid
A beautiful and truly unique documentation engine and static site generator.
Orchid
Orchid is a brand-new, general-purpose static site generator for Java and Kotlin, with a focus on extensibility and aimed at developers looking to improve their technical documentation. Orchid was born out of a desire for better-looking Javadocs and frustration with how difficult is it to manage large Jekyll sites and keep it up-to-date with your code.
Orchid supports a variety of plugins, including a wiki, static pages, blogs, and much more. It aims to have high compatibility with many of the existing static site generators, such as Jekyll, Gitbook, and Hugo, so that migration to Orchid is painless. And if you can't find a plugin to do what you need, Orchid provides an intuitive way to add your own private plugins and a rich API so you can make your site as beautiful and unique as an Orchid.
…