Naming Conventions
From DLXS Documentation
Revision as of 10:31, 7 August 2007
Several naming conventions have evolved in the writing of the DLXS Middleware. Being familiar with them will help when looking at and possibly making changes to the Middleware code.
- Subclass module names
- Variable names for most common object instantiations
- Method names
Subclass Module Names
Subclass modules generally carry some portion, even if abbreviated, of the name of its superclass ancestry. For example, the top-level DLXSClass.pm is subclassed by BibClass.pm and FullTextClass.pm. The latter is in turn subclassed by TextClass.pm and FindaidClass.pm. When TextClass.pm needs to be subclassed for a particular collection, the collection id is used, with the first letter capitalized, followed by "TC" to represent "TextClass". So, in the case of "Making of America", whose collection id is "moa", the collection subclass would be called MoaTC.pm.
See DLXS Object Class Hierarchy.
Variable names for most common object instantiations
Many DLXS Middleware-specific objects are created and used during the running of the CGI progam. When an object is "new-ed up" or instantiated in Perl, a variable which is "blessed" as an object of the class in question, is created. A convention has evolved for the naming of the variable by the calling code. Most of the variables have three-letter names (though a few have names of more than three letters). The most common ones are listed below. On the left is the object (from the module/Class name). On the right, a typical name for the variable that holds the reference to the object.
Being a bit familier with these object names should ease the task of looking through code.
Class name | variable name |
CollsInfo object | $cio |
GroupInfo object | $gio |
ProcIns object | $pio |
DlpsSession object | $dso |
ApplicationResult object | $aro |
XPat object | $xpat |
XPatResult object | $xro |
SearchSet object | $xro |
SearchHistory object | $sho |
DLXSApp object | $app |
TextClass object | $tco |
BibClass object | $bco |
FindaidClass object | $fco |
Bookbag object | $bbo |
BookBagItem object | $bbi |
QueryFactory object | $qf |
TerminologyMapper object | $tm |
Method Names
DLXS Programmers try to give methods names that are as self-documenting as possible. Names are written in proper case; one string with no spaces, in which the words are marked only with a capital letter.
Examples include:
- GetMainSearches
- Layer1ResultFormatter
- BuildKwicLink
- BuildViewEntireTextLink