How to use this document:
-
Read the General section (all of it)
-
Read the section on the particular file type you are interested in
-
Rules cascade. That is rules are applied with precedence general to specific (with specific having more precedence). So, e.g., if no file naming rule for a particular file type then it derives from rules in general section.
Contents
-
General Rules
-
Definitions
-
File Names
-
Layout
-
Xml Layout
-
File Specific Rules:
-
N(Ant) Files
-
Xsl Files
-
Html Files
-
SQL
-
Code
-
Common
-
C#
-
Java
-
UCC
-
Upper Camel Case naming: e.g. UpperCamelCase. Note acronymns should only capitalize first letter e.g. XmlFile not XMLFile. This applies even if acronym only has 2 letters e.g. UI (user interface) would be Ui.
-
LCC
-
Lower Camel Case naming: same as but first word does not have first letter capitalized. e.g. lowerCamelCase
-
LCU
-
Lower Case Underscore: words are all lower cased with underscore and word separator
-
LCU: all lower case with word separator '_'. Version numbers should be separated with '.'
-
Directory Names all lower case with underscores.
-
Always use tabs rather than spaces.
-
Tab-Spacing: 2 (Since using tabs rather than spaces this is not that relevant as individual users may configure tab spacing as they wish. However when needed for considerations of alignment this value is relevant).
-
Wrapping (line 80 rule??).
- Content/Block braces should start on a new line e.g.:
// java/c#
public void foo()
{
...
}
// css
td.large
{
...
}
Layout
This applies to all xml type files including: (x)html, xsl, xsd, ...
-
All files should have striped appearance. This is obtained by correct indentation. This is as follows:
-
After an open tag: 1. CR (Carriage Return i.e. enter key) 2. indent 1 tab stop. This applies no matter what the content of the tag (text or other tags).
-
On end tag: content (being text and not another tag): 1. CR
Example:
<Root>
<Melville>
was a man....
</Melville>
<Moby>
<Dick>
....
</Dick>
</Moby>
....
</Root>
Some exception are allowed:
-
need not always indent after root tag of document e.g.:
<html>
<head>
...
</head>
-
Any tag whose content is text only and is short enough that it content + start tag + end tag fit on one line.
-
Tags where internal content layout matters e.g. <pre> tag in html.
Naming Conventions
All names must conform to XML rules (e.g. rules for QNames - any normal element/attrib name must start with alphabetic or '_' and may contain only alphanumeric + '_'). Unless otherwise specified by schema/language should have:
-
XML Elements:
- UCC
-
Attributes:
- LCC
-
Variable Names:
-
All lower case.
-
'.' separator for areas e.g. build.tmp, '-' for normal word separation e.g. web-template.
Naming
-
All templates named in LC with '-' as word separator (follow xsl: name conventions).
-
Variables names are LCC. Prefix with g_ for global or put in a special namespace (?? http://www.openkf.org/xmlns/
-
Certain inline tags in html need not have their content on a separate line. Tags such as: 1. <strong> 2. <em> 3. a tag etc
Layout
-
Open bracket for a block on new line.
Referencs
-
http://www.unc.edu/~jwatt/writings/naming_conventions.html
-
Naming
- private member variables prefixed with '_'.
-
Comments
-
Summary comment on class obligatory.
-
Comments on ALL public class members (exception: get/set).
Follow standard conventions for that language. See Msft docs and the standard libraries.
Java see Sun Coding conventions and conventions in standard libraries.
Comments
For recommendation on javadoc comments see [3].
References
-
http://gee.cs.oswego.edu/dl/html/javaCodingStd.html
-
http://www.infospheres.caltech.edu/resources/code_standards/java_standard.html
-
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html