PDA

View Full Version : [Poll] Commenting - Good or Bad?



Jahova
27-05-2008, 04:26 PM
- Do you use commenting? -

Well, I was just thinking - In HTML & PHP, I comment alot.
But I don't see other people commenting when using html.

I find that by commenting, the HTML & PHP code, I can remember things more easier and also, it just makes the code easier to read.

- How do I comment? -

In HTML, you can comment by;
Adding; <!-- before the comment, and..
Adding; --> after the comment.

In PHP, you can comment by;
Adding; // before short comments, and..
/* and */ after blocks of comments.

- Commenting good or bad? -

Some people think commenting can make codes look bulky, ugly or hard to read, but I think it's the opposite.

As I don't see alot of HTML anymore with comments, I was just thinking if people have stopped commenting as they might think it's a bad idea.

What do you think?

seniorJOSH
27-05-2008, 04:34 PM
When, I've coded I've used comment.
It's very useful on free/opensource scripts.

Jahova
27-05-2008, 04:36 PM
Yeah, when sometimes I use a base from open-source projects.
I would be terribly lost without them.
They sure can be life-savers.

- Tom

seniorJOSH
27-05-2008, 05:06 PM
Yeah, when sometimes I use a base from open-source projects.
I would be terribly lost without them.
They sure can be life-savers.

- Tom


Yeah. =D

Hypertext
27-05-2008, 09:02 PM
I comment on heavily when I'm working with teams in PHP, in Html, there isn't too much you need to comment on because it's self explanatory whereas a complex file opener function in php could have a simple /* File Opener */, which can save a lot of time for yourself aswell (if your tired...mt dew :)), when working by myself just opening and closing divs - easier to keep track of, and basic php stuff.

But I got a big job working at an office in Chicago so I'll have to do a LOT more commenting from now on.

redtom
27-05-2008, 09:15 PM
Depends, if its my code and I'm working alone then no, but if I'm editing something or working with someone I try to comment on areas to remember where everything is and what is does but I don't comment as much as I would like to.

F32
27-05-2008, 09:38 PM
I only usually comment on variables.

Dentafrice
28-05-2008, 01:26 AM
I usually comment to phpDoc standards.

Commenting HTML isn't that useful unless you are commenting where certain divs end.

<!-- navigation -->
<div id="navigation">
blablabla
<div id="test">hlbalbkadlfjs</div>

<!-- /navigation -->
</div>

Hypertext
28-05-2008, 02:34 AM
why on earth would you comment on variables nasri, there really self explanatory.

Dentafrice
28-05-2008, 03:00 AM
Not really.



<?php
$database['server'] = 'localhost'; // MySQL server
$database['username'] = 'root'; // MySQL username
?>
That, easy for non-coders to read

Hypertext
28-05-2008, 03:53 AM
But if your using reasonably named variables it should be obvious enough.

Agnostic Bear
28-05-2008, 06:06 AM
Ok stop center aligning your text, it's extremely annoying to read.

Jme
28-05-2008, 10:34 AM
I only comment my code when i'm building for clients, so that it's easy for them to understand what's going on. I also need to use it in my college assessments.

Klydo
29-05-2008, 06:31 AM
I comment all the way through development, prevents confusion and saves a lot of time when editing larger files. As you can do a find/search for a particular comment and you go instantly to it. Once I launch a site I will remove them to save some bandwidth and space, even if it's a small proportion.

Want to hide these adverts? Register an account for free!