5

A lecturer just told a class of final year developers approx 50 people that commenting our code should be banned and we shouldn't write comments within our code in case we cause confusion

Comments
  • 3
    There's an ounce of truth to everything.. But sadly people fail to see the correct action to take :(

    Comments are good, but you need to maintain them.. Why aren't we teaching good things in school D:

    There is something to be said for code written well enough to not need comments though
  • 4
    Comment the why, not the what.

    What the code is doing should be obvious from the code itself so comments there are redundant and needs to be maintained (They will almost always end up out of sync with the code and thus their value will become negative)

    Short and properly named functions/classes/methods go a long way, if it isn't immediately obvious what a section of code does, break it out to a function/method with a good name.

    If you are doing something strange, use comments to explain why. (This should be very rare, i mostly comment performance hacks, workarounds for bugs in third party code and // TODO: ... for parts that just suck but can't be fixed right now due to business reasons (I always create an issue for it in our issue tracker and include the id + url for the issue in the comment)
Add Comment