Code conventions

This are the official programming standards Cherrycake follows.

Cherrycake uses the JavaScript conventions for entity naming, file naming and code structure. Of course, you can use your favorite conventions in your Cherrycake app.

Entities

  • camelCase for variables, properties and methods.

  • PascalCase for types, classes and modules.

  • UPPER_CASE_SNAKE_CASE for constants.

For example:

define("DEFINE_NAME", true);

$variableName = null;

class ClassName {
    var $propertyName;
    function methodName() {
        [...]
    }
}

$objectName = new ClassName;

File naming

Class names, module names and directories follow the same PascalCase convention, take a look at the Files structure section for more information.

Code structure

Feel free to use the structure methodology you prefer in your code. Cherrycake's own choice is tabs instead of spaces and a somewhat typical multi-line approach to function declarations and overall tidiness.

Here's an example code with some of this conventions in place:

If you're contributing to the Cherrycake Engine, please follow this conventions.

Last updated

Was this helpful?