-
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.
-
What do you mean "not to spread out"
just use the '
-
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?
-
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.
-
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.
-
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.
-
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.