Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Suggested prefixes for classes and objects
Message
From
27/09/2006 05:46:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
26/09/2006 17:32:47
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01157359
Message ID:
01157419
Views:
32
Peter,
I agree in general. However there are few points I do different and suggest to be that way.
1) FoxPro beautify tool reserved words and symbols 'No Change' unless you're doing it for small code snippets where you can see all code or you're sure beautify wouldn't cause hard to catch bugs. Several ways back I showed a case where beautify couldn't interpret a command line and caused hard to catch bug changing the casing. If your code has winAPI code in it you'd want to be sure their names not be touched at all.
2) oApp vs goApp. g is redundant. oApp is a well known public variable and it's the only public variable in an application.
3) 3 letter prefixing should not be so strict. ie: pg is just good for a page. Using btn,cmd or frm,top for same things are not good IMHO - overloading prefixes with properties. A button whether small or large is a button A form either toplevel,in top level or in screen is a form etc.
Cetin


>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
>
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform