ViCE Documentation
A Portable, open source, modular software for playing various trading card games.
|
This chapter discusses the coding standards adhered to when writing code for ViCE. Patches that don't adhere to these standards will not be considered for inclusion in ViCE, so plese read this document carefully.
Variables, functions, and methods should have the first word completely in lowercase and subsequent words capitalized. These names should not be separated by underscores, hyphens, or any other method of separation. Their names should also be concise and self-descriptive.
Example:
string myName; int myPetAge; string aShortStory; void jobAppliance();
The naming rules for variables apply to constants, except that words should be completely uppercase and separated by underscore.
Example:
const string MY_NAME; const int MY_PET_AGE; const string A_SHORT_STORY;
The naming rules for variables and constants apply to classes, except that every word should be capitalized and without any method of separation.
Example:
class StandardPerson { [...] } class StrangePerson { [...] }
Code should be indented using four spaces and respect the K&R style with respect to closing and openning braces.
Example:
void main() { int personAge; string personName, personJob; int petAge; string petName, petTrick; // Method to fill the job appliance formulary void fillAppliance() { [...] } }
The code should be separated by blocks, each block being a related group of methods, cycles, etc. Variables should always appear within the first few lines of a function or method, even they are related to some block of code within the body of that function or method.
Example:
void main() { int personAge; string personName, personJob; int petAge = 13; string petName = "Felix"; string teachNewTrick = new Trick(petName, petAge); }
Function, method and class declarations should have their parameter delimiters close to their name. Cycle expressions should have their parameter delimiters separated by one space.
Examples:
void fillForm(string name, string job, int age) { [...] } for (i = 0; i <= myGuess; i++) { [...] }