Contact Yart for a relaxed conversation
Your Name * Message *
Your Email *  
Your Phone   
Our Phone:        03 8685 8718 (within Australia)
61 3 8685 8718 (outside Australia)
Contact Yart

Melbourne Content Management and Flash developers

 

for designers, agencies and your website

Resources / General Work Instructions / ABC2009 Coding Conventions
ABC2009 Coding Conventions

SQL Conventions:

  • Tables that exist upon installation and store Abc related data to be prefixed by "Abc"
  • Other tables that are created dynamically but store Abc related data to be prefixed by "AbcAuto"
  • Table names are plural if they hold a number of entries of an object
  • Fields are named in uppercase with no spaces eg FirstName
  • The first field in all tables is a primary key with identity specification called "AbcId"
  • Foreign keys are named with the prefix "FK" in front of the table name that they are the foreign key to eg [FK AbcPages]
  • When writing SQL in code all sql statements are to be uppercase
  • Table and field names are to be enclosed in [] eg select [name] from...
  • Never execute a sql query from your code, use the class SqlFunctions

c# conventions:

  • Class fields are named with a "_" followed by the field name from the database (where relevant) eg _firstName. First charcater is lowercase
  • Property names are the same as the field names they represent minus the _ eg FirstName and first letter capital
  • Other variables are named like this FirstName not first_name
  • Under no circumstances should strings or numbers be embedded in source files. Declare strings as constant instead using an uppercase naming convention eg private const string MASTER_PAGE_EXTENSION = ".master";
  • Comment all methods
  • Comment all if statements if they have lambda's or more than one condition
  • Add comments liberally inside functions
  • Class comments should be descriptive, see ContentContainer for a good example
  • UI classes to be named like this AbcDeletedMenuItem
  • Declare class variables only when you need them unless it would result in a double delcaration

General formatting

  • Methods to be separated by two line spaces
  • After a list of field delcarations place a space in your method
  • In if statements, don't use {} if there is only one line
  • After a } there is always a blank line
  • Use two spaces not a tab to indent

Grouping of Code in c# Files

  • Constants region
  • Variables region
  • Properties region
  • Initialisation region - Constructors/Destructors (if present)/Page_Load
  • Events region - responses to actions on Controls
  • Methods are ordered alphabetically within regions

Other conventions:

  • None yet

See also the article on preventing SQL Injection.

The latest at Yart
Search: