Forums / Setup & design / Three problem I always face when I program and design

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

eZ debug

Timing: Jan 18 2025 15:15:49
Script start
Timing: Jan 18 2025 15:15:49
Module start 'content'
Timing: Jan 18 2025 15:15:50
Module end 'content'
Timing: Jan 18 2025 15:15:50
Script end

Main resources:

Total runtime0.9665 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.9531180.8125
Module start 'content' 0.00550.8407 768.7656532.4531
Module end 'content' 0.84620.1202 1,301.2188332.7266
Script end 0.9664  1,633.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.3904210.0002
Check MTime0.00140.1469210.0001
Mysql Total
Database connection0.00060.060910.0006
Mysqli_queries0.908694.01081910.0048
Looping result0.00170.17871890.0000
Template Total0.937997.020.4689
Template load0.00180.187020.0009
Template processing0.936096.853220.4680
Template load and register function0.00010.012010.0001
states
state_id_array0.00100.106510.0010
state_identifier_array0.00130.138820.0007
Override
Cache load0.00150.1526260.0001
Sytem overhead
Fetch class attribute can translate value0.00120.123630.0004
Fetch class attribute name0.00080.082930.0003
XML
Image XML parsing0.00070.077330.0002
class_abstraction
Instantiating content class attribute0.00000.000530.0000
General
dbfile0.00210.2178270.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs