4

I've always found commenting my code tedious, is it better to comment as I code or wait until its stable and then comment all in one go at the end?

Comments
  • 5
    I usually do it in the end because I'm lazy. Unless I'm doing something crazy and I know I won't remember what it's for later. In that case, I comment as I code
  • 5
    It depends. Try to write code which explains itself.

    When ever I do put comments in my code I do it right away and then delete if I delete that piece of code as well.
  • 0
    @uuppi what is this sorcery?!
  • 1
    I believe it's better to do it at the end, after you have fully optimized the block of code.
  • 3
    One nice little trick I've been doing is using log lines explaining what each stage is doing. You'll need to be mindful of their levels (usually they end up at DEBUG level) but it means your app has a big old audit trail of what it is doing, should anything go wrong, and you've got descriptive lines of text throughout the code.

    That and try to write your code so it's more like a sentence. English prose are easy to read.
  • 1
    With so many projects having deadlines shifted late in the game, I comment as I go - you never know if the business willI give you the time to comment before you go live and get shuffled to another task. I tend to find PMs will cut timelines the closer we get to release to please the client.

    I may take a ++minute each block up front to complete a project, but it has saved huge amounts of time down the track and given me some breathing room on the other side.
  • 0
    We (1000+ devs on same code base) usually don't comment much. The comments you run into are similar to:

    if(foo && specialCase) {
    resetUser () //my_name&project - need to clear all user settings to avoid corrupt userContextObject if application will return from suspended state with same user before timing out against some but not all sub-systems (jira wsxp-1148)
    }

    Then during next chill period we go through the important core/engine files and see where most divergences/diffs are between projects and try to rewrite that in a better way.
  • 0
    @Messer 1000+ devs on same code base?! What does the product do?
  • 0
    @simeg shared/core components AAA-Games
Add Comment