Comment on How to properly document code?

aluminium@lemmy.world ⁨10⁩ ⁨months⁩ ago

For new code I’m writing I’m using mostly JsDoc function headers where on public methods of classes and exported functions. With one or two sentences explaining what function does.

Also try to explain what to expect in edge cases, like when you pass am empty string, null, … stuff of that nature - for which I then create unit tests.

I also always mention if a function is pure or not or if a method changes the state of a class. On a sidenote I find it odd that almost no language has a keyword for pure functions or readonly methods.

source
Sort:hotnewtop