Main Content

mp_0034: Number of lines in a function

Since R2024b

Guideline Publication

Control Algorithm Modeling Guidelines - Using MATLAB®, Simulink®, and Stateflow®

Sub ID Recommendations

  • JMAAB — a

MATLAB Versions

All

Rule

Sub ID a

The number of lines in a function shall be kept below the limit.

Example — Correct

  • Lines of the range that can be collapsed at the function line in the editor are counted.

  • The help text just below the function line should be collapsed and counted.

  • The number of lines in the libinfo function is 88 in the following example.

Custom Parameter

  • Number of lines

Rationale

Sub ID a:

  • When a function has too many lines, it can be difficult to understand and maintain the function. Separating it by each feature deepens understanding of the functions and can limit the range affected by changes.

Verification

Model Advisor check: Check number of lines of functions (Simulink Check)

Last Changed

R2024b

Version History

Introduced in R2024b