JavaScript API Reference/Programming Conventions

Names

Use “camel case” to name variables, object properties and function:

var employeeInfo = new Object();
employeeInfo.firstName = 'Galileo';
employeeInfo.lastName = 'Galilei';

function displayEmployeeInfo(employeeInfo) {
...
}

One possible exception to this naming rule is when the object properties directly reflect the database field values. In this case you can use database field names as property names, to reduce the number of different names that WFR developers will need to remember:

reservation.date_start = ...;
reservation.date_end = ...;

Functions that return values (but do not change any object or variable state) should have a get prefix:

function getReservation(res_id) {
...
}

Functions that change object or variable state should normally have a set prefix:

function setCurrentReservation(reservation) {
...
}

Event handler functions that are attached on user events, such as “user clicks on the Confirm Room button”, should have an on prefix and also should match the name of the user event object (button):

function onConfirmRoom() {
...
}