 |
|
 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: Remarks?
Try debugging an application that's around 1000 pages of code (or a few hundred thousand lines of code) that has under 100 comments.
Comments being like:
' Step 1
' Step 2
' Loop through data
Not every line needs to be commented, many things would only really need commenting at the top (ex: the purpose of the routine), or within a loop with multiple if elseif statements. Basically for what the condition is if true/false whatever, just so it's completely clear.
A lot of commenting depends on how simple a program is, or how it's designed. Enums, Types, global variables are very good places that comments are needed (just so it's clear to people debugging it in the future, or you months/years later).
There are many situations that would call for comments, others will certainly post, but here are a few examples (note: this doesn't actually do anything, and might be missing a () or 2, but just for an example).
Private Function CalculateDistance() as Double
Do
DoEvents
Distance=(((Distance+Sqr(Distance^2E34))/CoordsXYZ) MOD 2)) *24.585673+Distance/(1/3) + 24*365*c
Loop Until Distance >= c^c
CalculateDistance=Distance
End Function
' What does the above do? How long would it take to remember exactly why it's done?
Public Const c = 300000000 ' Speed of light - rounded, actual 299,792,458 m/s
|
Most code that I write makes sense without too many comments, granted I have large variable/routine names. Others while it makes since to me, it only does since I know what's intended - and only to others if they know what it's supposed to do.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
22-04-2003 at 02:32 AM |
|
|
vbgen Level: Moderator
 Registered: 10-10-2002 Posts: 876
|
Re: Remarks?
if i may add...
i agree that leaving comments is a tedious task, especially if you want to comment properly.
BUT, heavy commenting is not good practice, it is discipline.
like others might say as well... sometimes even the simplest code can be forgotten in time.
when i code programs for other people, i leave heavy comments, especially when they might have a different way of coding from me.
when i code for myself, i leave just as much heavy commenting too.
one reason why employee type programmers have to leave heavy commenting on their part is so that when their programs have to be updated, or if they leave work unfinished, or if they are working in a team, then it is very important that you do not leave your work only understandable to you. responsibility perhaps is the word?
everything i have said is just my opinion. no offense to anyone, okay?
____________________________
Been busy trying to take a second degree <--it's not working out...
|
|
23-04-2003 at 06:01 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: Remarks?
This will sound strange to some of you, but I actually comment programs as I code even if it's a few line thing. Of course, not detailed stuff, just general comments. Meaning that when doing a loop, I'll instinctively comment what it does before writing the loop.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
24-04-2003 at 09:20 PM |
|
|
Shock Level: VB Lord

 Registered: 30-03-2003 Posts: 150
|
Re: Remarks?
it may sound weird but ive been programming ever since i was 7. I started on my grandfather's PCjr., which the default startup was something like BASIC version j.
I guess all these years of instinctive programming (like I program like people write books...I just know what to do) made it unneccesary for me to remark everything. Its like when learning to do something, you just make a mental note "this does this" and i remember.
What really gets me tangled up is VaRiAbLeS. they give me a headache, like how I wrote it. In my youth all i did was make RPGs, since they could be mostly text and pretty much all of the coding you do is readily apparent. You can imagine having a million varialbes that all look the same like HP, H.P., Hitpts. and Hpoints (if your wondering HP is current hp holder for battles and the like, H.P. is the constant hp when not in battle, Hitpts. would be hit points AFTER applying bonuses from items and such, and Hpoints would be a seldom used variable lets say if i used an item that would last a time). As you can see the confusion becomes very obvious. so variables, as much as i hate to comment on 500 variables, IMO its the only really important remarks. Most other coding can be understood by reading it, variables cannot.
But thats just me. When i write essays and the sort I just sit down and type a thousand words. when I code i usually just type and type, without a plan or the such. I used to use remarks for planning, such as
fight:
do
if time = true then DOTURN
loop
doturn:
'input turn code here
goto fight
but even later on i found it very unneccesary, by using subroutine names such as HUMANPLAYERTURN, or by using extended varialbes such as BASEHITPOINTS or the sort.
but everyone has their own personality, and i repsect people who can super-organise everything they do and make very few mistakes. I guess it depends if your programming professionaly or as a hobby.
|
|
25-04-2003 at 02:56 AM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: Remarks?
I've been programming since about 1982 or 1983 I believe... After so much time, you kind of forget. But it was during the 8088 processors as the top of the line stage, a little while before the "fast" 286's came out.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
25-04-2003 at 03:51 AM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1658
|
Re: Remarks?
My first computer had a 5-1/4in (360k I believe) bay that the entire OS fit on (MS-DOS2.x [thinking 2.11]), it had an optional low density 3.5in floppy (720k) as an expensive upgrade.
One of my first programs was a little murder mystery, exploration of a area using one-two word commands to navigate. It was a few thousand line program... with no comments - anywhere. Not surprisingly, I had to re-write it when I got qbasic (I had no clue what anything was supposed to do, only used a-z for variables too). Also got it down to under 500 lines - with comments.
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
25-04-2003 at 06:36 PM |
|
|
|
|
 |
 |