The OPR Developers have agreed on a common set of rules for the Perl code
implementation. These rules are designed to make the code as easily readable and
understandable as possible for other developers and to ensure consistency over
the whole system code.
Currently all the code is contained in the CVS package OprControlSys.
In Perl each class is contained in a different .pm [module] file. The filename is the same as the class name. The class names should be descriptive as much as possible, using descriptive suffixes like:
- ClassName
- ClassNameInterface: the Interface [also known as Abstract Class]
- ClassNameBase: the Base class
- ClassNameStruct: this class is just a container for data [like a C struct]
- ClassNameProxy: this class is a proxy to the real class
In the code itself, it preferable to put one command per line, with this style for the if/then/else construct:
if(...) {
...
} else {
...
}
Also the comments should be indented with the code they refer to, generously spread throughout the source code.
Standard headers will be available in the relevant package[s] so that all files provide a basic set of informations.
The following coding conventions will be enforced:
- "use strict"
- descriptive variable names [NOT like j, jj, h1...]
- method names always start with a capital letter
- variable names always start with a lower case letter
- filehandle names are written in all capital
- the use of filehandles is discouraged, objects of the class IO::Handle should be used instead of filehandles. IO::Handle provides an OO wrapper around filehandles. [perldoc IO::Handle for documentation]
- access to class/object data should be realized through accessors and mutators [Perl doesn't enforce encapsulation so it's up to the developer to be clean]
- complex data structures should be embedded in objects, eventually providing iterators
- operators based on side effects or default variables should NOT be used as they clutter the code and make it diffficult to read and maintain
- if absolutely necessary, side effects and default variables should be explicitly described in the comments to the code
The methods should always be created with a comment block. This comment block should contain the following meta-tags:
#SIG (the method signature) -> (the method return value)
#DES a description of what the method does...
#DES on as many lines as it's needed.
The use of meta-tags will make it possible to automatically generate the documentation for a class. This is analogous but simplified with respect to POD.
This page created by FST [safai@slac.stanford.edu] on 01/04/2002 at 7.15pm.