Results 1 to 7 of 7

Thread: Putting In Your Comments...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Omaha, NE, USA
    Posts
    28
    Alright... I'll admit it... I don't usually put green into my code. However, I know for a fact that I will be coming back to the project I am currently working on at a later date to update, and therefore MUST use comments. Tell how you like to put your green into your code? I am looking for an easy to read and comprehend way of including comments into my code without making everything look too spread out. Thanks in advance.
    - Ovid -

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    What do you mean "not to spread out"

    just use the '
    NXSupport - Your one-stop source for computer help

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Location
    Omaha, NE, USA
    Posts
    28

    Comments

    I meant not TOO spread out. I know HOW to put in comments, I wont to know in what fashion other people do it. For example, if you just add the comments on the same line, you have to scroll over to read them in many cases. OR if you put them directly above the line they describe they can get confused with the lines below. See what I mean? How do you do it?
    - Ovid -

  4. #4
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316

    Comments

    My personal preference is to comment out all of my Variable at the being of each sub/function. This way I alway know what is doing what before I even begin looking over the code involved. Then I tend to place comment within the subs, usually at key points where I figure I will either have to make changes in the future, or just not forget how something was done. And finally, I create a readme file and add it to my project as a related file. The readme file usually will include a list of all variables, functions, subs, forms/controls(ect), and give some short documentation of what they do. I find that if I know I will be updating a program in the future, spending the extra time now, seems to avoid the headaches later.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I'm not a big fan of comments but i'm using them whenever i think my code get's too unselfexplaining. And when it get's to a more than 3-level indentions i usually put a explanation after each indention, on the first line.

    You could put a bunch of comments on top of each file, telling what you can do with it. Also if you want you can put comments before each procedure.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Guest
    if i am about to undertake some complex logic i tend to write the entire subroutine in comments, all the way down the page.
    When i start coding it, i simply replace the comments with the relevant line of code, leaving in the bits that may not be clear in a few months time.


  7. #7
    Guest
    Hee is an example of how I would use it.

    Code:
    Dim MyScore     ' Used to keep score
    MyScore = 100   ' Our starting amount of money
    
    ' Gamble MyScore using "i" to help Randomize numbers
    For i = 1 To 100
       Print i
       Call GambleIt (i)
       MyScore = MyScore + GambleIt
    Next i
    When there are little short and 1 line codes, I indent and place my comment there. If there is a long set of code then I put it at the top of the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width