Constant definitions at top
ID | STAT-1 |
Title | Place constant definitions at the top of the function. |
Priority | Recommended |
Severity level | 9 |
Description | Constant definitions shall be placed at the top of the function, after defining global/persistent variables. |
Rationale | That way they can easily be found and identified. |
Avoid:
function testConstants(x)
y = 3 * x;
MAX_Z = 100;
z = min(y, MAX_Z);
end
Instead use:
function testConstants(x)
MAX_Z = 100;
y = 3 * x;
z = min(y, MAX_Z);
end