Do You Comment Your Code?

Discussion in 'iOS Development' started by Steaps, Oct 26, 2009.

?

Do you comment your code?

  1. Yes

    36.4%
  2. Sometimes / Somewhat

    39.4%
  3. Nope

    24.2%
  1. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Just curious, do you comment your code?
  2. ZunePod

    ZunePod Banned

    Joined:
    Aug 28, 2008
    Messages:
    1,340
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    I try to do as much as possible (especially when in team projects) time wasted figuring what is going on could be used doing something useful.
  3. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Yeah, in team code, it's basically necessary.
  4. Nburnes

    Nburnes Well-Known Member

    Joined:
    Jan 3, 2009
    Messages:
    9,022
    Likes Received:
    767
    Device:
    OnePlus One
    I do somewhat, because that is what I was taught in my computer programming class.
  5. cOde0010Joy

    cOde0010Joy Member

    Joined:
    Apr 26, 2009
    Messages:
    451
    Likes Received:
    0
    Device:
    iPad 2 (White)
    i don't code iPhone apps, but when i program, i try my best to put comments. It helps a lot when keeping track of things rather than tracing it all over again. Plus, when its a team project, its important for other members to at least get a hint on what that certain code segment does when reviewing it. When referring to programs i have done long ago, comments usually help make me understand it faster. It helps in debugging too!
  6. Collateral

    Collateral Active Member

    Joined:
    Sep 23, 2007
    Messages:
    1,974
    Likes Received:
    6
    Device:
    iPhone 3GS (Black)
    I comment

    Please Register or Log in to view images

    because i have to remind myself what i was doing with my code. lol.
  7. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    Commenting is very important for team projects, as mentioned above, as well as personal things - After staying up until 3-4 AM the previous night coding, upon reviewing the code later, you may think to yourself WTF is this. Commenting is a good habit and its best to do it while writing the code, not afterwards, as that way it is less of a chore, and it can slow down/organize your thought process which can cut down on time wasted debugging code with silly errors.

    To put it simply, just do it.
  8. muhu

    muhu Member

    Joined:
    Feb 27, 2009
    Messages:
    86
    Likes Received:
    0
    Device:
    iPhone 4S (White)
    Absolutely. It only takes a few conditionals and loops before I start to lose track of where I am at. Most of the stuff I code is open source and made for the benefit of others anyway.

    Commenting helps out all parties involved. It is one of the first things taught in a programming class. Though I will never get used to flow-charts. Blegh.
  9. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    If you don't comment, you're a fool. Team projects aside, when you go back to your code months later, without comments, you will need to figure out what it does. It's an enormous time waste to not comment code.

    That said, I don't. I tend to use descriptive code. ex, [PTColor darkenColor:aColor byFactor:factor]; Although that is never a good enough excuse to not comment. The truth is that when I get coding, I want to finish the current method and add code later. I almost never go back and add comments.

    Exceptions where I almost always comment include places where the I could very easily get mixed up. Most notably, when using switches to handle the button presses on UIAlertViews. I always comment which branch is the "Okay," and which branch is "Cancel." //Or whavever other options the alert may have.
  10. SmexyPenguin18

    SmexyPenguin18 Active Member

    Joined:
    Dec 27, 2007
    Messages:
    1,749
    Likes Received:
    0
    Device:
    3G iPod touch
    did you just call yourself a fool?

Share This Page