Reply LinkBack Thread Tools Search this Thread
Old 15-01-2008, 09:38   #21 (permalink)
lkjklllkkklii
Registered User
 
lkjklllkkklii's Avatar
 
Join Date: Jan 2008
Posts: 33
as a newbie... the first thing i think of is the speed of the connection of my client ... i do not comment if it is wap.. i dont care about my long comments if im using a server side language...
  Reply With Quote
Old 01-02-2008, 23:54   #22 (permalink)
johnranjan
Outsourcer
 
Join Date: Jan 2008
Posts: 1
I use commenting for PHP. Mainly I comment on the functionality of the code and also for some function I use in coding.
  Reply With Quote
Old 02-02-2008, 00:36   #23 (permalink)
freelancr
Web Developer
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,007
Quote:
Originally Posted by Limbo
CSS Sample - commented throughout.

Code:
/* living room */ #product-nav li.living a:link, #product-nav li.living a:visited /* garden */ #product-nav li.garden a:link, #product-nav li.garden a:visited {} /* homepage */ #home #content .intro {margin:20px 0;padding:0;color:#eee; solid}

Examplified.

No offence, but you are saving nothing by writing css like that. Because it isn't clearly set out you have several errors in there which are hard to spot at a quick glance. Firstly. What's the point in this when there are no curly braces afterwards with attributes in?
Code:
#product-nav li.living a:link, #product-nav li.living a:visited

Secondly, you aren't being consistent, now you include the curly braces
Code:
#product-nav li.garden a:link, #product-nav li.garden a:visited {}

Thirdly, you have the word "solid" randomly in there, which I can only guess is the remains of a border attribute that was there at some point.
Code:
#home #content .intro {margin:20px 0;padding:0;color:#eee; solid}

Don't mean to be such an ass, but encouraging people to code this way is not constructive at all. I'm by no means perfect but find the following the most readable way of writing code.

Code:
/* screen.css Created by Name <user@domain.com> */ body { background-color: #123456; } /* Layout */ div#container { width: 760px; margin: 2em auto; }

This is designed to be a constructive criticism which I hope you find helpful. I do not mean to be patronizing at all, but apologize if that is how you feel this message comes across.
__________________
  Reply With Quote
Old 02-02-2008, 01:42   #24 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,457
I usually aim to write code that is more or less self commenting by using descriptive function names, variables etc. Same with CSS.

It's not really hard to guess what these functions do:

function dbAddNewUser(...)

function dbDeleteUserRecordByID($id)

function dbGetUserRecordByLastName($lastname)

I used to comment like mad. These days I only comment if I've done something weird or slightly obscure and I want to remind myself why I did it. Or occasionally if I use some kind of hack to solve a problem, I usually leave a comment with the intention of going back later and figuring out a better, cleaner way (although I rarely do).
  Reply With Quote
Old 02-02-2008, 19:04   #25 (permalink)
Mongoose
Senior Member
 
Mongoose's Avatar
 
Join Date: Oct 2007
Location: Olympia, WA
Posts: 151
Send a message via AIM to Mongoose
I've been trying to make myself comment more of late. I'm especially striving to keep my CSS well-documented and organized by element type, etc.

On the other hand, I lost points last week for over-commenting in a computer science assignment...
  Reply With Quote
Old 02-02-2008, 23:21   #26 (permalink)
Cborrow
I like code.
 
Join Date: Dec 2004
Location: Chesapeake, VA
Posts: 200
Send a message via AIM to Cborrow
I usually don't comment my code, unless I am creating a large library and lots of people will be using.
__________________
Code { for thought }
"My programs never have bugs, they just develop random features."
  Reply With Quote
Old 03-02-2008, 05:12   #27 (permalink)
samuelcotterall
Interactionist
 
Join Date: Sep 2006
Location: Manchester
Posts: 174
I'm a front-end developer and I comment my code when I'm working with others on it, although I think my class/ID names are pretty self explanatory.

I only ever put a line in my code, but tend to create a text file will a dictionary of all my class names, ID's, colour hex codes, images and how I've approached certain things.
__________________
  Reply With Quote
Old 03-02-2008, 06:39   #28 (permalink)
combat sheep
Trained to Kill.
 
combat sheep's Avatar
 
Join Date: Oct 2006
Location: Southport, UK
Posts: 308
Send a message via MSN to combat sheep
If you cant read html or css without comments get another job.

Sometimes programming requires it but all comes down to the scale, I find I comment alot when I'm using different technologies together such as web services and PHP or flex and RPC. I comment important things that are easily forgotten.
  Reply With Quote
Old 03-02-2008, 07:27   #29 (permalink)
proc355
Trailer Trash™
 
proc355's Avatar
 
Join Date: Sep 2006
Posts: 851
comment if it's not clear, or if you need documentation to be auto-generated

"# this method is called add_two_integers, it takes two integers and returns an integer" is a waste of space

"# method to return the sum of widgets & wodgets" is ok, but still superfluous if your method is called "sum_of_widgets_and_wodgets"

mind you, if it's not clear, it's crap code… (odd algorithms—or obfuscating your genius—excepted)

i add comments to partial templates when doing dynamic pages simply so i can see what partial is responsible for what html easily

...
<!-- foo.list.tmpl -->
<ul>
<li>
...

etc., but i seldom bother with static html
__________________
meh.
  Reply With Quote
Old 03-02-2008, 10:10   #30 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
Quote:
Originally Posted by combat sheep
If you cant read html or css without comments get another job.
Come on. I find it helpful to comment some things in CSS just to remind myself why I did something. HTML not so much. Besides, Firebug is better than View Source.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8