Automating Google Workspace (GWS) & more with Apps Script
Programming Design Guidelines
1. Programming Design Guidelines
Programming Design Guidelines
Collected and composed by Stefan Ziegler.
May 2002.
Hungarian Notation of Programming Code
Generals
Developping application there is often the question of how to name variables,
constants, objects, etc… Developping within a tem the standardization of name
conventions is very important. The set-up of a unique reglementation for naming
classes and categories of objects.
This is necessary for a common understanding within a team and for further
development or maintenance of an application.
History
Dr. Charles Simonyi developed the convention at Microsoft, where it is used in the
Windows source code. Microsoft says it’s known as Hungarian notation because the
prefixes make the names seem to be non-English and also because Simonyi is from
Hungary.
Description of a module (a “bean”)
Every module has a descriptive intro
‘-----------------------------------------------
‘module:
‘author:
‘date:
‘comment:
‘-----------------------------------------------
‘-----------------------------------------------
‘history:
‘<date>: comment
‘-----------------------------------------------
‘-----------------------------------------------
‘function:
‘author:
‘date:
‘comment:
‘parameters:
‘output:
‘-----------------------------------------------
It is recommended inserting comments during the development. The code is more
readable while development is in progress and documentation would not be forgotten.
Annotation for SAP ABAP programming
Usage of the following header is mandantory:
Page 1 of 5
2. Programming Design Guidelines
*********************************************
* Name: program name
* Title: short title
* Update? please insert no or the updated db name(s)
*********************************************
* Function:
* fill in a short description of this program (1-3 lines)
*********************************************
* Author: First author of this program
* Date: creation date of this program
*********************************************
* History:
* Change-# + Date + Developer’s Name + Case / Project-#
* Description
* …
*********************************************
Naming of Variables
First of all there are some basics about naming of variables. Every variable is to be
defined at the beginning of the code. Names can be 255 characters long. The names
can consist out of letters, numbers, underscores, etc… The datatype is to be named at
the beginning of the name of the variable. You must not use reserved words for names
of variables. Split merged words by using capitals like: sFirstnameLastname
Using VB try to switch on the explicit declaration of variables by using option
explicit. Using this switch each variable has to be defined before you can use it.
Code Documentation
Essential paragraphs of code should be documentd. Using the apostroph ‘ is shorter
and more readable.
GUI Screen Objects
Having a GUI form there are a lot of components a user can work with. Writing the
code it is important having a unique convention of naming these components.
Object Prefix Example
Form frm frmFileOpen
Check box chk chkReadOnly
Combo box cbo cboEnglish
Command button cmd cmdCancel
Directory list box dir dirSource
File list box fil filSource
Frame fra fraLanguage
Image img imgIcon
Page 2 of 5
3. Programming Design Guidelines
List box lst lstPolicyCodes
Option button opt optFrench
Text box txt txtGetText
Dictionary dic dicList
Object obj objUserTable
ODBC Database db dbAccounts
Field collection fld fldCustomer
For a detailed list see: http://support.microsoft.com/support/kb/articles/q173/7/38.asp
Additional annotation: constants are defined in capitals.
Sample of Detailed Dialog Box
Find enclosed a sample screen shot of a detailed dialog box:
1: group, frame
2: label with text box
3: drop down field
4: check box
5: command buttons, with <OK> as default button (react with <enter> key),
<Abbrechen> (=<cancel>) goes with <esc>-key, and <Übernehmen> is deactivated
6: tabs
7: slider
8: radio buttons
9: spin button
10: progress bar
Page 3 of 5
4. Programming Design Guidelines
fig.1: sample screen shot of detailed dialog box
Naming of Functions
Functions and variables should have a name explaining their mission itself. Using this
readability increases tremendous.
Having the scope of producing international code for international programmers
english is the language used for naming of variables.
Structure of Code
Writing programming code branches, statemanrs, conditions, etc.. are included.
Having the best overview, parts of the code belonging together shoul be structured
with tabs. (Ann.: one tab is equal four spaces)
Bad example:
SubCheckNetworkAddress
SNetworkAddress”192.168.100.120” bad:
For i=1 To 100 no declaration of function
/
comment
CallProofAddress no decleration of
variables
If bNetworkAddress = True Then mixture of english /
german
CallDruckerVerbinden content of i / z ?
Page 4 of 5
5. Programming Design Guidelines
End If
PrintsNetworkAddress usable:
structured
z = z + 1 function calls with call
Next i
End Sub
Enclosure
Find enclosed a short overview of naming Java objects.
Page 5 of 5
6. http://support.microsoft.com/support/kb/articles/q173/7/38.asp
Object Prefix Example
--------------------------------------------------------------------------
Form efrm frmFileOpen
Check box chk ReadOnly
Combo box cbo cboEnglish
Data-bound combo box dbc dbcEnglish
Command button cmd cmdCancel
Data dat datBiblio
Directory list box dir dirSource
Drive list box drv drvTarget
File list box fil filSource
Frame fra fraLanguage
Grid grd grdPrices
Data-bound grid dbg dbgPrices
Horizontal scroll bar hsb hsbVolume
Image img imgIcon
Label lbl lblHelpMessage
Line lin linVertical
List box lst lstPolicyCodes
Data-bound list box dbl dblPolicyCode
Menu mnu mnuFileOpen
OLE container ole oleObject1
Option button opt optFrench
Picture box pic picDiskSpace
Shape shp shpCircle
Text box txt txtGetText
Timer tmr tmrAlarm
Object Prefix Example
------------------------------------------------------------------------
Vertical scroll bar vsb vsbRate
Animation button ani aniMailBox
bed Pen Bedit bedFirstName
Checkbox chk chkReadOnly
Picture clip clp clpToolbar
Communications com comFax
Control ctl ctrCurrent
Data control dat datBiblioDirectory
Directory list box dir dirSource
Common dialog ctrl dlg dlgFileOpen
Drive list box drv drvTarget
File list box fil filSource
Form frm frmEntry
Frame (3d) fra fraStyle
Gauge gau gauStatus
Group push button gpb gpbChannel
Graph gra graRevenue
Grid grd grdPrices
Pen Hedit hed hedSignature
Horizontalscrollbar hsb hsbVolume
Image img imgIcon
Pen Ink ink inkMap
7. Keyboard key status key keyCaps
Label lbl lblHelpMessage
Line lin linVertical
MDI child form mdi mdiNote
MAPI message mpm mpmSentMessage
MAPI session mps mpsSession
MCI mci mciVideo
Menu mnu mnuFileOpen
Object obj objUserTable
Option Button (3d) opt optRed
Outline control out outOrgChart
3d Panel pnl (3d) pnlTitleList
Report control rpt rptQtr1Earnings
Shape controls shp shpCircle
Spin control spn spnPages
Timer tmr tmrAlarm
Vertical scroll bar vsb vsbRate
Database Objects Prefix Example
--------------------------------------------------------------------------
ODBC Database db dbAccounts
ODBC Dynaset object dyn dynSalesByRegion
Field collection fld fldCustomer
Field object fld fldAddress
Form frm frmNewUser
Index object idx idxAge
Index collection idx idxNewAge
Macro mcr mcrCollectUsers
QueryDef object qry qrySalesByRegion
Query qry qrySalesByRegion
Report rpt rptAnnualSales
Snapshot object snp snpForecast
Table object tbl tblCustomer
TableDef object tbd tbdCustomers
The following table lists standard third-party vendor name prefix characters to
be used with control prefixes:
Vendor Abbreviation
-------------------------------------------
MicroHelp (VBTools) m
Pioneer Software Q+E Database p
Crescent Software c
Sheridan Software s
Other (miscellaneous) o
Objects Prefix Example
---------------------------------------------------------------------
Alarm(Microhelp) almm almmAlarm
Animate(Microhelp) anim animAnimate
Callback(Microhelp) calm callback
Combo Box(Pioneer) cbop cbopComboBox
Combo Box(Sheridan) cbos cbosComboBox
DB_Check(Pioneer) chkp chkpCheckBox