Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Programming standards

Chris Dickenson edited this page Dec 21, 2016 · 5 revisions

The old code base is a mess of random code with no standards future additions must follow these standards as well as re-writing old code must follow these. (Eventually the whole code base will follow these standards)

Variable Names

Must be descriptive of what the variable is for, be all lower case, start with a lower case letter and if it contains multiple words each word must be separated by an underscore

Good Examples:

  1. $auction_data
  2. $feedback_count
  3. $is_buy_it_now

Bad Examples:

  1. $count (count of what?)
  2. $VALUE (not lower case, also value of what?)
  3. $_name (does not start with lower case letter)

Function names

Must be descriptive of what the function is for, be in camelCase, start with a lower case letter and only have one distinct function (only do one thing)

Function parameters

Function parameters should be named as such that glancing at the first line of the function should tell you exactly what the function does

function getUserData($username)

Indenting

Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting.

SQL formatting

Capitialise all SQL keywords (SELECT, FROM, VALUES, AS etc.) and leave everything else in the relevant case.

When the sole purpose of a query is to count the results use sql COUNT(id) instead of php numrows()

Strings

Strings should be quoted with single quotes, never double quotes

For more info review https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md

Clone this wiki locally