Conventions
Function/method code layout
Functions and methods should be laid out as follows
Style Conventions
Two spaces between methods in a class file.
Comment block endings if they are large. e.g.
end % methods
at the end of methods blocks in a class file, as you typically can not see themethods
at the start of the block at the same time as theend
.Try to keep class files below about 500 lines.
Short methods can remain in the main class file.
Longer methods should be in their own files.
For consistency it is preferred to use a
@className
folder for all concrete classes even if there is only one.m
file in it. Short abstract classes can be left bare if desired to distinguish them from concrete classes.Unless there is an exceptional reason, all functions should be in a module sub-directory for neatness.
Max line length is 100 characters but you can break this rule occasionally if that makes sense. It is better to sometimes have an exceptionally long line than to break up that line in an ugly and hard to read way.
Format Guidelines
Ident size should be 4 spaces (i.e. two indents should be 8 spaces). Do not use tabs. These are the settings used by default in the MATLAB editor.
Last updated