Three problem I always face when I program and design

Author Message

Softriva .com

Wednesday 28 March 2007 9:54:33 am

Dears

I always face three problems when I design, program, write code, etc.

I just need few minutes of your time to help me out.

The issues

<b>1. Naming Convention</b>
When I am done with a site and I look back to my code, class name, css classes/IDs, I could see that there is no consistency in naming the variable . There is no convention followed in naming the these variables, classes, etc.
My concerns, what is best naming convention. I searched on the net and found many different conventions which at end it confused me.

<b>2. CSS Classes/IDs</b>
I start with small css file then it gets bigger and bigger until it get out of control. I mean it has many unnecessary classes/IDs. How do you guys track your css classes/IDs to ensure that unnecessary classes/IDs are removed. How do start?

<b>3. Commenting.</b>
My code is poor when it comes to comments; I don't know when and what to comment. How far do I go in writing comments--just lost.

Thank you in advance.

paul bolger

Wednesday 28 March 2007 9:58:07 pm

Not sure if this is really the right forum for these questions, but here's my thoughts:

1. Your naming conventions should reflect the semantic meaning of the code. If you change the formatting later (and I'm talking about CSS here) the class or id name should still apply.

2. A big CSS file is much, much better than big HTML files! From what you say though I suspect that you are suffering from 'Class Overproduction' - you are giving elements classes instead of using your selectors. It is much better to give your content an id of 'content' and then use selectors such as #content p, #content table td etc than give the p elements classes *unless they need a style which is different to the one they normally use in that context*. I tend to find that only about 10% of my CSS rules address a class, the rest just address elements by their context.
The best tip I can think of to write good CSS is use the Web Developer

http://chrispederick.com/work/webdeveloper/

extension for Firefox, and use the Outline Current Element function to see where in the DOM the element you are trying to address is.

3. I tend to comment my CSS fairly heavily, and my HTML not much at all. There shouldn't be much in the HTML besides content anyway.

As far as eZpublish template files go: if you spend two hours working out how to do something, comment it. Commenting is also good for others who may need to try and unpick your work later. Try to imagine you are encountering the code for the first time, would it make sense without explanation?

Of course the next step in commenting is write down how you achieved that nifty little code trick, and the best place for that is here.

Paul Bolger

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.