Virtual Web Designs
Virtual Web Designs
Home Page Company Profile Portfolio Support Latest News Jobs Contact Us Prices Members Area

Virtual Web Designs

Services
Home
Website Designing
Website Graphics
e_Commerce
Consultancy
Search Engines
Bespoke Software
VrRange of Software
Database Development
Domain Names
Hosting Packages
Website Language Translation
Partnerships
 
Search Our Site
  Coding Standards - Virtual Web Designs
     
  Taken from our own internal document VWD-129 Issue c
 
This is the Virtual Web Designs coding standard document. This should assist anyone who wants to modify the code or work on active development. Anyone who wishes to contribute code must adhere to these guidelines. Code not following these standards will be rejected.

Above all, write code that is easy to read and maintain. Comment blocks of code and functions at all times.

Naming Variables
  • Use all lower case.
  • Use _ to separate words, e.g. $green_colour_value
  • Use descriptive names (except loop variables).
  • Loop variables can be of the usual variety: $i, $j, $k, etc.
  • Count variables should follow the format $*_count, e.g. $bug_count
  • Global variables should be prefixed with g_
  • Temporary variables should be prefixed with t_
  • Parameters and variables passed from forms that have been cleaned of any special SQL chars (i.e. slashes) should be prefixed with c_
  • Uncleaned function parameters should be prefixed with p_
  • Uncleaned variables passed from forms should be prefixed with f_
  • Other variables are prefixed with v_, v2_, etc.
  • Never prefix with l_ or o_ or q_ (visually confusing)
  • $query and $result should be used for SQL query and results respectively
Naming Functions
  • Use all lower case.
  • Use _ to separate words, e.g. setup_page_breaks()
  • Keep functions to 5 words or less
  • Functions that print should be prefixed with print_.
  • Try to use prefixes to group functions (i.e., email_, news_, etc.)

Naming Classes

  • Use FirstLetterOfWordIsCaptilised style
  • Variables that are class objects should have the prefix coo_
Naming Files
  • Use all lower case.
  • Use _ to separate words, e.g. view_new_bugs_page.php
  • Use .php file extensions
  • Filenames must be less than 32 characters in length. This plays nice with older file systems like Mac OS.
  • Included files should be suffixed by _inc.php
SQL formatting
  • UPPERCASE all SQL keywords:
  • $query = "SELECT *
    • FROM $g_mantis_bug_table
    • WHERE id='1'";
  • Always assign a query string to a variable. This makes code easier to debug when problems occur. Do not create the query in the call to the function.
  • Break up SQL queries over multiple lines to be easy to read.
General Formatting
  • Use TABS with a size of 4
  • Follow the table formatting of existing pages
  • Use <?php ?> for php delimiters.
  • Try not to print/echo HTML unless it's short or in a function loop
  • Do not use the EOF construct
Miscellaneous
  • Don't use the ?: construct except in very rare cases. It is confusing and has a lot of bug potential.
  • Avoid magic numbers. The only magic numbers in use should be 1 and 0 and their meaning should be obvious.
Page Guidelines
  • The first item should be the copyright notice
  • At the bottom will be the footer information and closing print_ functions.
Braces and Parantheses
  • Parantheses should be right after a function name, e.g. function() not function ()
  • Parantheses should have a space right after a keyword (if, while, for), e.g. for (...)
  • Formatting of braces is illustrating below. We use unmatched placing.
  • Arrays should be referenced with no spaces, e.g. $arr['index'] not $arr[ 'index' ]
  • for (...) {
  • blah
  • }
  • or
  • if (...) {
  • blah
  • }
  • if ... else blocks should be in this format:
  • if (...) {
  • blah1
  • } else {
  • blah2
  • }
Comparisons
  • The NOT operator should be placed next to its operand. No spaces, e.g. !$value
  • Parentheses should be used for grouping, especially with multiple comparisons, e.g. if ( ( null == $val ) && ( null == $val2 ) )
Strings
  • Use spaces around the string concatenation operator, e.g. 'str ' . $value . ' str2';
  • Use ' instead of " if there are no variables or special characters.
Comments
  • Use the # symbol for line commenting, not //
  • Use /* */ for block commenting unless you nest /* */ comments. Generally, only use this during development.
  • Use @@@ followed by a brief message (BROKEN, TEMPORARY, etc) as a "look at this" indicator. Leaving your name next to is a good idea. This way critical items can easily be found.
Editor Features
  • Search and replace in multiple files
  • Goto line number
  • Syntax highlighting
  • Adjustable TAB spacing

Testing

Alpha Versions

Alpha testing is simulated or actual operational testing by potential users / customers or an independent test team at the developers' site. Alpha testing is often employed for off-the-shelf software as a form of internal acceptance testing, before the software goes to beta testing.

Beta Versions

Beta testing comes after alpha testing. Versions of the software, known as beta versions, are released to a limited audience outside of the company. The software is released to groups of people so that further testing can ensure the product has few faults or bugs. Sometimes, beta versions are made available to the open public to increase the feedback field to a maximal number of future users.

Final Release

Final Release comes after beta testing.  Once we are happy with the beta testing, the software is then put into the public domain.

 

 
Copyright @2001-2008 Virtual Web Designs
Virtual Web Designs is a Trading Name of Webnetics UK Ltd.
Marstercard Visa Visa Electron Delta Solo JCB Maestro   WorldPay
Telephone 01493 701796 | Fax 01493 700459 | Email sales@vwdesigns.co.uk
Green Hosting - 100% Carbon Neutral
 
Webnetics UK Limited is registered in England: 05094309
Registered Office Glenmaric, Marsh Road, Halvergate, Norwich, Norfolk NR13 3QB, England
UK Web Design Association