Ga naar hoofdinhoud

Naming conventions

1. General

Every variable name should be in English and should be as descriptive as possible. The name should be in

  • snake_case in PHP and
  • camelCase in Javascript.

The name should not be longer than 30 characters.

2 Variable names for id's

Summary

supergroup_identifier : sg1

group_identifier : sg1_gp1

field_name : tenant_id

record_counter : 2

element_identifier : group_identifier . ''. field_name . '' . record_counter = sg1_gp1_tenant_id_2

record_identifier : group_identifier . '_'. record_counter = sg1_gp1_2

class_name : 'fg_' . element_identifier = fg_sg1_gp1_tenant_id_2

class_name : 'fc_' . element_identifier = fc_sg1_gp1_tenant_id_2

** element_id wordt element_identifier **

General

Every variable name should contain an identifier for supergroup and group. Referred to as group-identifier.

V.e. sg1_gp1_tenant_id

Question: should we change this to field_name_group-identifier? Answer: No. We use the group-identifier to identify the group when splitting the $_POST.

When there are more than one records in a form, a record-identifier should be added to the variable name. The result_key.

V.e. sg1_gp1_tenant_id_0

Question: should we use the result_key in all cases? Answer: Yes. Standardize the naming convention.

Question: should we explain result_key to be of equal length even as the number of records grows beyond 10? Answer: Yes. Allow for 100 records.

Standard variables

Element ID

PHP: $element_identifier JS: elementIdentifier

Consists of: group-identifierfield_namerecord-identifier

CompoundedID

PHP: $compounded_id JS: compoundedId

Consists of: group-identifier_record-identifier

Class names

formgroup: fg_element_identifier formcontrol: fc_element_identifier

Form names

Type of forms:

  1. Group with single record : form_sg1_gp1_001
  2. Group with multiple records : form_sg1_gp1
  3. Multiple groups with single records : form_sg1
  4. Multiple groups with multiple records : not yet implemented

Button names

Button names have a scope of a record of a group of records.

Current:

Save: submitbutton_save_sg1_gp1_1

Delete: row_delete_btn_sg1_gp1_1

Proposed:

button prefix : button_

button type : save, save_close, delete, back, add, pdf, upload, copy

supergroup-identifier : sg1_

group-identifier : sg1_gp1_

Example: save button for:

Group with single record : button_save_compounded_id = button_save_sg1_gp1_002

Group with multiple records : button_save_group-identifier = button_save_sg1_gp1

Multiple groups with single records : button_save_supergroup_identifier = button_save_sg1

Multiple groups with multiple records : not yet implemented