• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

does work get any more boring then this?

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Try doing assembly language without comments
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
If you understand the language, and you understand the problem, then the comments will in most cases be superfluous; of course, this is assuming you're not working on extremely esoteric systems of Gordian knot complexity. I'm assuming that by coming onto ATOT to complain about comments that you are not. :)

:beer:
 

NikPreviousAcct

No Lifer
Aug 15, 2000
52,763
1
0
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?
 
Jul 12, 2001
10,142
2
0
lol...well i am dealing with a complex robotic system and the concepts of the forces being applied and calculated can become very complex, which makes it hard when there are no comments and poorly named variables.
 
Jul 12, 2001
10,142
2
0
i comment very little when I am working on it...but if i am going to leave the group I am in, then I usually go back and comment so others can use the program
 

EmperorIQ

Platinum Member
Sep 30, 2003
2,003
0
0
i usually only comment when it is needed, like
//temp string for testing purposes, try to dynamically allocate later

but commenting is important and easier for others, wouldn't it be? No matter how good you are at programming, if you're working in a team with others you have to comment, people's approaches to problems are always different. by commenting you will save the person trying to fix your code a lot of time.

on a side question, does anyone get lazy when naming variables?

like using string a; instead of string UsrName;
 

cerebusPu

Diamond Member
May 27, 2000
4,008
0
0
/* I think of myself as a good commentor because i leave comments all over the place. In reality, most of my comments are useless because its just me talking to myself and no one understands it */
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
Originally posted by: EmperorIQ
i usually only comment when it is needed, like
//temp string for testing purposes, try to dynamically allocate later

but commenting is important and easier for others, wouldn't it be? No matter how good you are at programming, if you're working in a team with others you have to comment, people's approaches to problems are always different. by commenting you will save the person trying to fix your code a lot of time.

on a side question, does anyone get lazy when naming variables?

like using string a; instead of string UsrName;


I totally agree, I use to be really against commenting but having to work on 4-5 different programs with 7 other people it's very easy to forget what you're doing ...

and no it's no as easy a++ //Post increment a by 1 ... you can have constants in your equation that after a few weeks of not looking touching your program, you'll go back and wonder why that constant is there ...
 

DT4K

Diamond Member
Jan 21, 2002
6,944
3
81
I've been burned a few times when I went back to look at my own code 6 months later and wondered "WTF was I trying to do here".
Not to mention how much worse it is to look at someone else's code and wonder wtf they were thinking.
So while I am coding, I try to think about whether something will be clear to other developers, and if not, I comment it.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
Originally posted by: FoBoT
lets all post our source code! :thumbsup:

sub EditSchedule{
print header;
my $type = param("t");
my $name = param("n");
my $defrep = "";
my $defper = "";
my $title = "";
if($type eq "r"){
$defrep = param("n");
$title = "Editing schedule for: $defrep";
}
else{
$defper = param("n");
$title = "Editing schedule for: $defper";
}
my $template = "";
open TEMPLATE, "/afs/.usgs.gov/www/ca.water/htdocs/comm/schedit_template1.html";
while (<TEMPLATE>) {
$template .= $_;
}
close TEMPLATE;
my $end = "";
if ($defper){
$end = qq~person = "$defper"~;
}
else{
$end = qq~report = "$defrep"~;
}
my $existing = $database->selectall_arrayref(qq~select report, person, task, startdate, enddate, time from crts2_schedules where $end order by sortorder;~);
my $length = @$existing;
my $definitions = qq~
var type = "$type";
var name = "$name";
var defrep = "$defrep";
var defper = "$defper";
var existing = new Array($length);
~;
for (my $ii = 0;$ii < $length; $ii++) {
my $line = $$existing[$ii];
$$line[3] = dateFromSQL($$line[3]);
$$line[4] = dateFromSQL($$line[4]);
$definitions .= qq~
existing[$ii] = new Array("$$line[0]", "$$line[1]", "$$line[2]", "$$line[3]", "$$line[4]", "$$line[5]")~;
}
$template =~ s/-- DEFINITIONS --/$definitions/;
$template =~ s/-- TITLE --/$title/;
print $template;
exit;
}

sub SaveSchedule{
my $numlines = param("l");
my $type = param("t");
my $name = param("n");

# Get actual data from the form.
my @data;
for (my $ii = 0; $ii < $numlines; $ii++) {
my @line;
push @line, param("rep$ii"), param("per$ii"), param("tas$ii"), param("std$ii"), param("end$ii"), param("tme$ii");
push @data, \@line;
}

# remove old data from the database
my $section = "person";
if ($type eq "r") {$section = "report"}
my $action = $database->prepare(qq~delete from crts2_schedules where $section = "$name";~);
$action->execute;

# insert new data into the database
for (my $ii = 0; $ii < @data; $ii++){
my $line = $data[$ii];
$$line[3] = dateToSQL($$line[3]);
$$line[4] = dateToSQL($$line[4]);
my $action = $database->prepare(qq~insert into crts2_schedules values("$$line[0]", "$$line[1]", "$$line[2]", "$$line[3]", "$$line[4]", "$$line[5]", "$ii");~);
$action->execute;
}

# Back to the selection.
EditSelect();
}

sub dateToSQL{
my $date = $_[0];
$date =~ s~(\d+)[/ .-](\d+)[/ .-](\d+)~$3-$1-$2~;
return $date;
}

sub dateFromSQL{
my $date = $_[0];
$date =~ s~(\d+)-(\d+)-(\d+)~$2/$3/$1~;
return $date;
}
 
Aug 16, 2001
22,505
4
81
Originally posted by: FFMCobalt
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?

Hahaha!

I hope you are joking. The point od comments is to make it easier for someone else to understand the code just in case YOU are replaced or YOU work in a team.
 
Aug 16, 2001
22,505
4
81
Originally posted by: Shanti
I've been burned a few times when I went back to look at my own code 6 months later and wondered "WTF was I trying to do here".
Not to mention how much worse it is to look at someone else's code and wonder wtf they were thinking.
So while I am coding, I try to think about whether something will be clear to other developers, and if not, I comment it.

:heart:
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Originally posted by: FrustratedUser
Originally posted by: FFMCobalt
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?

Hahaha!

I hope you are joking. The point od comments is to make it easier for someone else to understand the code just in case YOU are replaced or YOU work in a team.
Not commenting = job security :evil:
 
Aug 16, 2001
22,505
4
81
Originally posted by: Skoorb
Originally posted by: FrustratedUser
Originally posted by: FFMCobalt
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?

Hahaha!

I hope you are joking. The point od comments is to make it easier for someone else to understand the code just in case YOU are replaced or YOU work in a team.
Not commenting = job security :evil:

True to a point hahaha.

Not commenting also = stuck in the same place forever &amp; getting flamed during a design review.
 

DT4K

Diamond Member
Jan 21, 2002
6,944
3
81
Originally posted by: Skoorb
Originally posted by: FrustratedUser
Originally posted by: FFMCobalt
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?

Hahaha!

I hope you are joking. The point od comments is to make it easier for someone else to understand the code just in case YOU are replaced or YOU work in a team.
Not commenting = job security :evil:

Not unless you work in some obscure language.
Otherwise,
not commenting = pissed off co-workers
 

Garet Jax

Diamond Member
Feb 21, 2000
6,369
0
71
Originally posted by: Skoorb
Originally posted by: FrustratedUser
Originally posted by: FFMCobalt
I've never commented my proggies. I don't understand what the deal with comments is anyway. What are you going to comment? The way a program works? Read the code. What you plan to have for dinner? Your shoe size? Why use comments at all?

Hahaha!

I hope you are joking. The point od comments is to make it easier for someone else to understand the code just in case YOU are replaced or YOU work in a team.
Not commenting = job security :evil:

Actually. It is the opposite. You are more important to the team and the company if they can count on you to comment things properly.

Not only this, but it is much easier to roll off projects and onto new ones if they know your code is well commented.