50

I promise (for myself) I'll comment my code from now on...

Comments
  • 1
    Awesome.

    Not pointing at anybody as I'm guilty myself, but especially those "magic" double underscore (accessor, delegator) props & methods need a comment or two... :)
  • 2
    Comments are lies.
  • 1
    But I named my methods right 😦
  • 2
    Document your interfaces.
    Write straightforward code with meaningful names.
    Comment only on messy or surprising parts of your logic.
  • 1
    I always say think of comments as something you want to explain to your future self after you forget everything you've just done. Then you'll hate writing them less and appreciate them more when you have them.
  • 0
    @devios1 that's good attitude, but think about code review: when a piece of code requires explanation, then it's not ideal to begin with. Sometimes the effort needed for explaining it is better directed towards making it straightforward so it doesn't require explanation.
    That said, of course sometimes there's no straightforward way, and sometimes there are pitfalls in the "obvious" solution. These demand comments.

    In other words, comments describe the anomalies in the code. One should strive not to have such things at all.
  • 1
    @elazar Can't disagree with that, but as I'm sure you know it rarely works out that way. ;)
  • 1
    @devios1 true. So it's not "cool, I've even commented it" but rather "well, that's the best I could have hoped for under the circumstances, but at least I have explained it in the comments".
  • 0
    1) Keep an eye on Cyclomatic complexity

    2) Docstrings

    3) Profit
  • -1
    I think you just posted the title here to start the discussion. You did not write some description or content related to it and leave the people or participants to write about that topic. You may be adopted an approach like https://analyzedu.com/writing-servi... and it is good and people like to participate in such discussion.
Add Comment