Class and Object Names
These are some notes from our design manual for your possible use and/or amusement. :-) There is not a lot new here but you may be interested in the way we pulled things together.
Note I set the FoxPro beautify tool to convert reserved words to lower case and symbols to match the first occurence.
Class and object names have no scope or type prefix but they should be preceeded with a three-letter prefix which denotes their function or base class. Since the prefix designates the function of the class, don't repeat this information. For example avoid ChkCheckBox1 in favor of ChkAuditReport. Or consider this horrible example from the Foxpro Help for the AddObject method:
Bad: frmMyForm.AddObject('cmdCmndBtn1','cmdMyCmndBtn1') && Up Cmnd button
Good: FrmMyOwn.AddObject('cmdUp','CmdBasic') && Up command button
You may wish to start class names with a capital letter and object names that do not match any class name with a lower-case letter.
See also Advanced Object Oriented Programming with Visual FoxPro 6.0 by Markus Egger (pages 237-244) for his take on naming conventions. The prefixes below match his very closely.
Unlike Marcus and the Codebook folks we do not make a naming distinction between a class and an object. Generally we think of an 'object' as being an instance of a class so they both get the same name unless there is more than one instance and then the extra objects get variations or more specific names.
For this reason we do not use 'C' for concrete class or 'A' for abstract class as others do. Also note that a variable which contains a pointer to an object of any class has type 'o' following the appropriate scope character or object name.
When we instantiate an application as a standalone object we store the reference to that object in a global variable called 'goApp'. Note: many people use 'oApp' for this.
If we place a business object in a form we might (depending on the context) refer to the business object as thisform.BizPeople (for example). If this form has a child form for the address we might refer to the city field on the Address form as: thisform.BizPeople.BizAddressCh.txtCity. Note that it is no use typing 'ThisForm' because the Beautify tool will soon change it to lower case.
Prefix Characters for Common Classes
General Function Pref Base Class Comment
Active Document Acd activedoc
Application App container Main application class
Data Behavior Object Bhv container Data behavior logic
Business Object Biz container Business logic
Button Btn commandbutton Small button on a toolbar
Check Box Chk checkbox
Collection Col collection
Column Grc column
Combo Box Cbo combobox
Command Button Cmd commandbutton Larger button with a caption
Command Group Cmg comandgroup
Container Cnt container Control Ctl control
Cursor Cur cursor
Custom Cus custom
Data Environment Env dataenvironment
Edit Box Edt editbox
Form Frm form
Form Set Frs formset
Graphical User Inter. Gui container Contains controls & little code.
Grid Grd grid
Header Grh header Grid header.
Hyperlink Hyp hyperlink
Image Img image
Label Lbl label
Line Lin line
List Box Lst listbox
Manager Mgr custom
Menu Mnu container
Menu Bar Bar container
Menu Pad Pad container
Middle Tier Class Mid custom
Miscellaneous Class Cls relation
OLE Container Control Ole OLEcontrol
OLE Bound Control Olb OLEboundcontrol
Option Button Opt optionbutton
Option Group Opg optiongroup
Page Pag page
Page Frame Pgf pageframe
Project Hook Pjh projecthook
Pop-up Form Pop SCX (1) SCX form with ShowWindow = 1
Relation Rel relation When actually used as relation.
Separator Sep separator
Session Ses session
Shape Shp shape
Spinner Spn spinner
SPT Helper Spt custom
Text Box Txt textbox
Timer Tmr timer
Tool Bar Tbr toolbar
Top-level Form Top SCX (2) SCX form with ShowWindow = 2
Peter Robinson ** Rodes Design ** Virginia