DEV Community

Discussion on: Self Documenting code isn't

tobias_salzmann profile image
Tobias Salzmann

Sadly, best practices/patterns/anti-patterns are often applied without understanding the problem they address.

And the solution seems to be similar in most cases: Understand why the best practice/pattern/anti-pattern is one, what the tradeoffs are and what that means for the specific case. Easier said than done, I admit.

In this case, There are some comments that are inherently important (why-comments) and some that are incidentally important (what-comments).
What I would prefer to do:

  • Refactor code into chunks that can be understood by reading names and type signatures.
  • Remove redundant comments
  • Keep the ones that still add value.