Procedures with a long parameter list are difficult to use because maintainers must figure out the role of each parameter and keep track of their
position.
set_coordinates: proc(x1, y1, z1, x2, y2, z2, x3, y3, z3); /* Noncompliant */
/* ... */
end set_coordinates;
The solution can be to:
- Split the procedure into smaller ones
/* Each procedure does a part of what the original set_coordinates procedure was doing, so confusion risks are lower */
set_origin: proc(x, y, z);
/* ... */
end set_origin;
set_size: proc(width, height, depth);
/* ... */
end set_size;
set_rotation: proc(yaw, pitch, roll);
/* ... */
end set_rotation;
- Find a better data structure for the parameters that group data in a way that makes sense for the specific application domain
declare point (3) float decimal;
declare size (3) float decimal;
declare angles (3) float decimal;
/* ... */
set_coordinates: proc(origin, size, angles);
/* ... */
end set_coordinates;
This rule raises an issue when a procedure has more parameters than the provided threshold.