Edgewall Software

Changes between Version 28 and Version 29 of TracDev/CodingStyle


Ignore:
Timestamp:
Dec 16, 2015, 12:51:11 PM (8 years ago)
Author:
figaro
Comment:

Added SQL coding conventions

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/CodingStyle

    v28 v29  
    5050 * Avoid using `except Exception`, instead making the exception clause as narrow as necessary to catch the excepted exception.
    5151
    52 == JavaScript
     52== Javascript
    5353
    54 !JavaScript code should follow [http://javascript.crockford.com/code.html these conventions] with the following exceptions and additions:
     54Javascript code should follow [http://javascript.crockford.com/code.html these conventions] with the following exceptions and additions:
    5555* Lines shouldn't exceed a length of 79 characters.
    5656* Use two spaces for indentation and refrain from using tabs.
     
    6767* Omit the curly braces for variables in Genshi templates, using `$var` rather than `${var}`.
    6868
     69== SQL
     70
     71While the Python and Javascript coding conventions differ from the SQL coding conventions, it is still important that we have them for code consistency and code legibility. Both of these make SQL code maintenance easier.
     72* Table and column names are singular and lowercase.
     73* Separate by underscore: `milestone_name` instead of `milestonename`.
     74* Reserved words are uppercase: `SELECT` instead of `select`, `INTEGER` instead of `integer`.
     75* Avoid abbreviations and if you have to use them make sure they are commonly understood.
     76* Do not prefix with `tbl` or any other prefix or Hungarian notation.
     77* Do not give a table the same name as one of its columns and vice versa.
     78
     79When presenting SQL code in the wiki, use the #sql preprocessor, as in `{{{!#sql`, so that the code highlights neatly.
     80
    6981----
    7082See also: TracDev