Coding Standards - EranOfek/AstroPack GitHub Wiki
- Package names shall start with lowercase letters (e.g., +imProc). A few (old) exceptions exit (e.g., +VO).
- Class names shall start with an uppercase letter (e.g., @AstroImage).
- Function and methods names shell start with lowercase letter (e.g., flat).
- Variable names shall start with an upper-case letter.
- Property names in a class shall start with an upper-case letter.
In cases where input arguments with some default are required and/or key,val input arguments are needed, we shall use the matlab "arguments" block, where keyword values are marked as "Args.":
function Result = funname(Obj, Args)
arguments
Obj
Args.Min = 1;
Args.Max = 5;
end
Be generous with comments in the code.
The help section should have the following format (with the exact indentation):
% Primary meaningful description line
% Input : - Var description. If not trivial, provide information.
% Default is X.
% - Yet another argument.
% Default is X.
% * ...,key,val,...
% 'Arg1' - Yet another argument. Default is X.
% Output : - First output arg.
% - Second Output arg.
% Author : Your Name (MMM YYYY)
% <Compilation>: Optional
% <Unknown Bugs>: Optional
% <References>: Optional
% Example: Url = VO.TopCat.searchTapList('SIMBAD TAP');
Each package/class should have a unitTest function. In the case of a class, this is a static function. The purpose of the unitTest function is to enable testing of the functions in the class/package.
Performance test file for the functions in the package. For example, if comparing mex vs. matlab, should return true if mex is faster than matlab.
A class should always reside in a directory that starts with "@" (e.g., @ImageComponent). The methods of a class shall reside in the same file as the class definition. An exception is the unitTest static function that shall reside in a separate file.