Download Segment - Technical Manual

Transcript
6 Coding Conventions
This chapter describes the coding conventions that has been used when coding Segment. I have really tried to use a consistent naming rules to ensure
that variables are given a logical name. However, there are occasions where
historical reasons have lead to exceptions to the rules given below.
In general Segment originally used the global variable NO indicating the current image stack quite extensively. The use of NO is however not encouraged,
and it is highly recommendable to in the function call indicate the current
image stack. Work is ongoing to completly remove the global variable NO,
but it takes time, please see wiki and relevant tickets on this matter.
6.1
Naming functions
Functions are always named in lower case letters only. The underscore letter
is not used with the exception of:
• Callbacks are named as functionname Callback.
• Functions for mouse motion callbacks are given names ending with
Motion.
• Some functions have helper functions that are only called from other
functions with the same name. These functions are named helper.
• Functions for mouse button up/down callbacks are given names ending
with Buttonup or ButtonDown.
Note that functions should not be ended with an end (Matlabsupports
both syntaxes). This is with the exception with objected oriented programming, see below.
6.2
Naming variables
The following rules apply:
• Global variables have all capital letters, i.e DATA.
13