[01] - Coding Convention
Code should be easily readable and be able to troubleshooted by someone who is not the writer. These conventions aid in this practice, and adhering to these rules will provide uniformity and clarity across multiple projects.
Naming
Style
There are many different kind of naming conventions, but for general variables in code, we will use Capitalized_Snake_Case.
camelCase is more ergonomic for typing, requiring fewer keystrokes, but sacrifices readability. One solution, if able, is to bind shift+space to "_"
Motor_On_Timer: TON;
Major_Fault_Flag: BOOL;
Total_Loop_Count: UINT;
Intent
Use names which both reveal your intent and removes the need for supplementing your code with comments.
// Bad - Put the UPS in to full capacity mode if the Power Supply 10 is in fault
IF SUP_10.flt THEN
UPS.smode := 1;
END_IF
// Good
IF PowerSupply10.HasFault THEN
UPS.mode := FULL_CAPACITY_MODE;
END_IF