Comments on poorly written code
ID | LAYOUT-7 |
Title | Comments should not justify poorly written code. |
Priority | Strongly recommended |
Severity level | 7 |
Description | Do not use comments to justify or mock poorly written code. Write proper code that requires no justification instead. |
Rationale | Readability will be improved if issues with the code are fixed immediately instead of documented in the comments. |
Avoid:
x = 2;
y = 3 * x; % TODO: take z into account.
% FIXME: This piece of ugly code is copied from StackExchange.
z=[1,23,8.1]*(x^3.1415)*sqrt(y);
Instead use:
x = 2;
y = 3 * x + z;
z = [1, 23, 8.1] * (x ^ 3.1415) * sqrt(y);