Design principles

As with many programming languages, code style remains a very important factor. Not only does it increase consistency in your code or make it less prone to errors, it also makes your code easier to read for people other than yourself.

A JOII-based application should follow the guidelines laid out in this section to maximize consistency and readability in the code.

Definitions, Properties & Methods

To clarify, PascalCase always starts with a capital letter. With camelCase, the first letter of the first word in the identifier is lower case, while the first letter of every subsequent word is uppercase.

This is important because JOII generates getter-and setter methods for you for protected and public properties using this style. For example, a property called real_name will have a getter method named getRealName().

It is considered being a good practice to document properties and methods using JSDoc formatted comment-blocks.

var SomeClassDefinition = Class({
     * @var number
    'public number some_random_number' : 42,

     * Randomizes some_random_number to the given maximum value.
     * @param number max_value
    'public randomizeNumber(number)' : function (max_value) {
        this.some_random_number = Math.round(Math.random() * max_value);

var def = new SomeClassDefinition();
def.some_random_number // undefined

def.getSomeRandomNumber(); // 42

def.getSomeRandomNumber(); // ?? 0 ~ 10

def.randomizeNumber("invalid"); // throws: Couldn't find a function handler to match: randomizeNumber(string)