In SupaKode we found that there needed to be some form of convention when it came to creating function names and variable names. The intention is to make sure that code is not duplicated and easily read by people who intend to use it or fix it, if there is a bug.
This is version 1.0 of the SupaKode naming conventions. It will apply to all future versions of SupaKode and Supa Comix code.
Variable Naming
PHP code differs from other coding styles to which it is similar to in the way that variables are named becuase you don't have to define a variable as something before you use. It can be created on the fly and the type of variable it is can change during the code. We have chosen to name the following types as such:
Variable Type - variable prefix
Integer - int
String - str
Boolean - bol
Array - arr
Object - obj - This does not include classes!
Mixed - mix - This is for variables that can have varying types
We also use this along side PascalCasing styles of coding. This is where the after the prefix is used the name of the variable is where all the words are joined together, no underlining or hypening and each word starts with a capital letter.
Examples:
- Integer for Counting Cats = intCatCount
- String for Cat name = strCatName
- Boolean for Cats having four legs = bolCatFourLegs (notice how numbers are written as text and not as number, only variations of a variable have numbers and they are at the end and must start at 0 but 0 is not written in the variable name.)
- Array of Cat Names = arrCatNames
Function Naming
Naming functions is something that we have to make sure is consistent, we have found that not really setting something like this causes confusion in the way of whether the function does what we think it does and to cut down on functions doing the same thing just named differently.
function prefix - Description of use
add - Not to be used as a mathamatical function, this usually just adds something to somewhere like a new key and value to an array
create - A collaboration of functions used to create something but not a new row in a table directly, see insert.
delete - This is used to delete something from a database table
fetch - This is used to retrieve data from a database table
finish - Used to finish something that has begun using the start function
format - This is used to apply a change or an alteration towards a string to make it into something else
get - This is used to retrieve something from somewhere but not a database table, for example a number from an array.
insert - This is used to insert rows of data into a database
is - This is used to check whether something is true, such as where there is an r in the word Rabbit (function could be called isRInWord)
load - This is used to move data from one place to an array or an array in a class
math - This is used to apply mathematical functions towards an integer
remove - Take away from something existing but not from a database table, like removing spaces from a string
select - For use with SQL Select statements
start - Used to start something, to be used in conjuction with the finish functions
update - This is used to update a row in a database
output - For directly putting something on the screen/page.
Other notes:
- All functions when listed together are to be done alphabetically, so speed up searching for it.
- Use of PascalCasing, see variable naming about this
- You can use other prefixs for functions just make sure that they do not use any of the above to avoid confusion.
File Naming
The naming of files is another important section of how Supa Kode will work, we wanted to make sure that people understood what types of files they would be using and where they could find certain peices of code. And so we have the following file name conventions:
- Files which contain lists of functions end in .func.php
- Files which are classes end in .class.php
- Files which are used for scripts which may be called more than once but are not actually a list of functions end in .script.php
- Files containing chunks of data which help the program work or even configure end in .data.php
- Files containing a list of constant declarations end in .constants.php
- Files which add to the file source array end in .source.php
However file naming is not as specifically strict as variable or function naming where some files don't even have to be named and those that are just pages do not need the above sections adding to them.





