Naming - Indentation - Documentation
The most important thing of standards is being consequent,
using the same choices of naming, code structure, etc.
Your code will be easier to understand and to write, you will easier remember variable, type and procedure names.
So, we don't force you to use the following standards, it's ok if you create your own and follow them. Only be consequent.
The most commonly used (and widely accepted) standards are marked in bold.
CONST ARRAY_SIZE = 15; => constants: all capitals, seperated by underscores
TYPE DayEn = (MON_DAY, TUE_DAY,...);
=> enum constants: all capitals, seperated by '_'
optional: use a unique suffix for that type
TYPE HoursSb = [0...24]; => subranges: suffix 'Sb'
TYPE CalendarAr =
=> types: suffix 'Ar'
PROCEDURE DoThis (inputVar:
=> procedures: start with a capital
=> parameters: start with a small letter
VAR toReturn: INTEGER;
nbr_items: CARDINAL; => local variables: use underscores
PROCEDURE Calculate_Nbr(...) =>
procedures: use underscores
INTEGER; => global
variables: use prefix 'g'
startHour: HoursSb; => local variables (only used in the module or procedure): start with a small letter, each new 'word' with a capital
partA_Parameter: HoursSb; => use underscores between capitals
Indent with 2 or 3 spaces (or with a TAB - you can edit the tab size in the modula-2 editor to your own taste):
i := 1;
a := Test...
Back to the top