zui: General Conventions
NOTE: These conventions are currently being rewritten for updated HTML5/CSS3 and progressive enhancement.
ZUI methodology always uses the conventions of the chosen platform/environment/framework wherever possible/feasible/realistic. The most important issue is consistency per project. As long as the project is consistent the conventions don’t matter so much to me.
- Indentation: soft tab (4) spaces
- Use whitespace i.e. after commas/colons, between declarations/expressions on a single line
- Comment everything (in appropriate language pattern e.g. phpdoc
- Never use “-” (dashes). Always use “_” (underscores). For easier text selection.
- If no framework conventions for directory structure exist then…
root/ /_assets/ /css/ style.css | common.css | default.css (choose) other.css /js/ /libraries/ jquery.js jquery.some_plugin.js some_other_library_plugin.js plugins.js script.js /_lib/ /functions/ some_function_library.php /LiteralClassName/ ChildClassName.php /LiteralClassName.php /_vendor/ /developer/ /library_or_project/ however the project ships | same structure as lib
or I’m left to my own devices I use the best of the above with the following conventions are used.
|_directory_name||Directory containing files that should not be loaded directly and could/should be protected.|
|directory_name||Normally viewable directory.|
|file_name.ext||Normally viewable file.|
One class per file. Child classes stored in directory by the same name as parent class.
|Indenting||Soft tab. (4) spaces.|
|Arguments||$argument, $argument. Space after commas.|
Variable, Class, CSS, html element naming
|Lowercase. Underscore for space.|
|Uppercase. With or without underscores for spaces.|
Coming. Need a way to include/share common stuff like this (shortcodes?) that was part of an included file from the pre-WordPress version of the site.
Naming conventions and coding standards
- pear coding standards
With some minor exceptions/preferences for things like using the “one true bracket”, flexible adherence to 80-120 character lines (especially for certain comments) and other spacing in classes. The point being that most the pear standards increase readability and improve consistency which is the goal, especially when you are working in teams where consistency is vital.
- ZEND Framework coding standards
Mostly the naming conventions especially for classes.
- Horde coding standards
More good patterns
- CodeIgniter Best Practices