Jump to content

Leszynski naming convention: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
disadvantages
Added details about the LNC tags, and a link to download the LNC Rename add-in
Line 1: Line 1:
The '''Leszynski naming convention''' (or '''LNC''') is a way of naming [[Object (computer science)|objects]] in [[programming]] and [[database development]] fields. The Leszynski naming convention is a form of [[Hungarian notation]] which emphasizes the use of three-letter (and occasionally four-letter) object type prefixes.
The '''Leszynski naming convention''' (or '''LNC''') is a way of naming [[Object (computer science)|objects]] in [[programming]] and [[database development]] fields. The is a form of [[Hungarian notation]] which the of - and -) .


For example, a developer wanting to store a string that contains a username might call it strUsername. Or, in a database, a [[Table (information)|table]] that stores prices for an online store might be called tblPrices. This makes it very easy to understand the type of something when just glancing over it, at the expense of syntactical and semantical noise. The tags are always [[minuscule|lower-case]] and each word of the object name is [[majuscule|capitalized]]. Spaces and underscores are not used.
The tags are always [[minuscule|lower-case]] and each word of the object name is [[majuscule|capitalized]]. Spaces and underscores are not used.


This naming convention is often used within the [[Microsoft Access]] community, and is standard in [[Visual Basic]] programming, but is not widely used elsewhere.
This naming convention is often used within the [[Microsoft Access]] community, and is standard in [[Visual Basic]] programming, but is not widely used elsewhere.

Hungarian notation (named after Charles Simonyi's native country) breaks down object names into the following elements:

[prefix(es)][tag]BaseName[Suffix/Qualifier]

The elements of the naming convention are described in the following table.

{| class="wikitable"
|-
!Component
!Description
!Example
|-
|Prefix(es)
|A lowercase letter that adds extra information to the tag
|p for Public variable
|-
|Tag
|A three-letter sequence indicating the object type
|tbl for table
|-
|BaseName
|A word or two describing the object. If several words are used, each starts with a capital letter, and there are no spaces between them
|OutlookContacts – contacts imported from Outlook
|-
|Suffix (RVBA), Qualifier (LNC)
|A word giving more specific information about an object
|ByDate – the data is sorted by date
|}


{| class="wikitable"
|+'''The Basic LNC Object Prefixes'''
|-
!Object
!Tag
|-
|Incomplete objects, backup objects, or objects that are under development
|_ or – (In Access 2000 and later, dashes sort to the beginning of the database object list.)
|-
|Hidden system objects
|zh
|-
|Displayed system objects
|zs
|-
|Programmatically created temporary objects
|zt
|-
|Backup copies of objects, for later copying or reuse
|zz
|}


{| class="wikitable"
|+'''The Basic LNC Variable Prefixes'''
|-
!Variable Type
!Tag
|-
|Local variable
|[no prefix]
|-
|Local static variable
|s
|-
|Module-level variable
|m
|-
|Public variable in a form or report module
|p
|-
|Public variable declared in the Declarations section of a standard module
|g
|}


{| class="wikitable"
|+'''The Basic LNC Database Object Tags'''
|-
!Object
!Tag
|-
|Class module
|cls
|-
|Form
|frm
|-
|Form (dialog)
|fdlg
|-
|Form (menu)
|fmnu
|-
|Form (message)
|fmsg
|-
|Form (subform)
|fsub
|-
|Macro
|mcr
|-
|Module
|bas
|-
|Query (any type)
|qry
|-
|Query (append)
|qapp
|-
|Query (crosstab)
|qxtb
|-
|Query (data definition)
|qddl
|-
|Query (delete)
|qdel
|-
|Query (form filter)
|qflt
|-
|Query (lookup)
|qlkp
|-
|Query (make-table)
|qmak
|-
|Query (select)
|qry (or qsel)
|-
|Query (SQL pass-through)
|qspt
|-
|Query (union)
|quni
|-
|Query (update)
|qupd
|-
|Report
|rpt
|-
|Report (subreport)
|rsub
|-
|Table
|tbl
|-
|Table (attached dBASE)
|tdbf
|-
|Table (attached Excel)
|txls
|-
|Table (attached FoxPro)
|tfox
|-
|Table (attached Lotus)
|twks
|-
|Table (attached ODBC)
|todb
|-
|Table (attached Paradox)
|tpdx
|-
|Table (attached SQL Server)
|tsql
|-
|Table (attached text)
|ttxt
|-
|Table (lookup)
|tlkp
|}


{| class="wikitable"
|+'''The LNC Table Field Tags'''
|-
!Object
!Tag
|-
|Autonumber (random non-sequential)
|idn
|-
|Autonumber (replication ID)
|idr
|-
|Autonumber (sequential)
|ids
|-
|Binary
|bin
|-
|Byte
|byt
|-
|Currency
|cur
|-
|Date/Time
|dtm
|-
|Double
|dbl
|-
|Hyperlink
|hlk
|-
|Integer
|int
|-
|Long
|lng
|-
|Memo
|mem
|-
|OLE
|ole
|-
|Single
|sng
|-
|Text (character)
|chr
|-
|Yes/No (Boolean)
|ysn
|}


{| class="wikitable"
|+'''The LNC Tags for VBA Variables'''
|-
!Object
!Tag
|-
|Boolean
|bln
|-
|CommandBar
|cbr
|-
|Control (generic; useful when cycling through controls on a form or report)
|ctl
|-
|Currency
|cur
|-
|Database
|dbs
|-
|Double
|dbl
|-
|Form
|frm
|-
|Integer
|int
|-
|Long
|lng
|-
|QueryDef
|qdf
|-
|Report
|rpt
|-
|Single
|sng
|-
|Snapshot
|snp
|-
|String
|str
|-
|Table
|tbl
|-
|Type (user-defined)
|typ
|-
|Variant
|var
|}


{| class="wikitable"
|+'''The LNC Tags for Form and Report Controls''' (may also be used in code referencing controls)
|-
!Object
!Tag
|-
|Attachment
|att
|-
|Bound object frame
|frb
|-
|Chart (graph)
|cht
|-
|Check box
|chk
|-
|Combo box
|cbo
|-
|Command button
|cmd
|-
|Custom control
|ocx
|-
|Frame
|fra
|-
|Hyperlink
|hlk
|-
|Image
|img
|-
|Label
|lbl
|-
|Line
|lin
|-
|List box
|lst
|-
|Option button
|opt
|-
|Option group
|grp
|-
|Page (on a Tab control)
|pge
|-
|Page break
|brk
|-
|Rectangle (shape)
|shp
|-
|Subform/report
|sub
|-
|Tab control
|tab
|-
|Text box
|txt
|-
|Toggle button
|tgl
|-
|Unbound object frame
|fru
|}


{| class="wikitable"
|+'''Some Typical LNC Names for Database Objects, Controls and Variables'''
|-
!Object/variable name
!LNC naming elements
!Description
|-
|tblEmployees
|tag + base name
|A table of employee data
|-
|qupdSales
|tag + base name
|A query that updates sales data
|-
|fsubDayMax
|tag + base name + qualifier
|A subform that shows the maximum day
|-
|intLines
|tag + base name
|An Integer variable to hold a value representing the number of lines in a Word table
|-
|curSales
|tag + base name
|A Currency variable holding a Sales value
|-
|pstrForm
|prefix + tag + base name
|A public String variable holding a form name
|-
|zztblContacts
|prefix + tag + base name
|A backup Contacts table, for copying and filling with imported data
|}

This article is taken from Helen Feddema's book, '''Expert One-on-One Microsoft Access Application Development''', Wiley, ISBN 0-7645-5904-4, with some modifications.



==External links==
==External links==
Line 9: Line 420:
*[http://c85.cemi.rssi.ru/access/Books/A97ExSol/indexc.htm Leszynski Naming Conventions for Microsoft Solution Developers]
*[http://c85.cemi.rssi.ru/access/Books/A97ExSol/indexc.htm Leszynski Naming Conventions for Microsoft Solution Developers]
*[http://www.acc-technology.com/namconv.htm MS Access Naming Conventions]
*[http://www.acc-technology.com/namconv.htm MS Access Naming Conventions]
*[http://www.helenfeddema.com/Files/code10.zip LNC Renaming Add-in – A free Access add-in that automatically applies the LNC to an Access 2000, 2002 or 2003 database]

[[User:Helen Feddema|Helen Feddema]] 21:56, 3 August 2007 (UTC)


[[Category:Source code]]
[[Category:Source code]]

Revision as of 21:56, 3 August 2007

The Leszynski naming convention (or LNC) is a way of naming objects in programming and database development fields. The LNC is a form of Hungarian notation which uses prefixes (called tags) to indicate the object type, control type or variable data type, and (optionally) the table field data type. Use of distinctive prefixes makes your database self-documenting; when you see frmSales in VBA code, you will know that it references a form, and when you see curSales you will know that it is a Currency variable. When selecting a query from a drop-down list, you will know that a query starting with qmak is a make-table query, while one starting with quni is a union query. This information will allow you to avoid errors such as using the SetFocus method (a control method) with a field, or trying to open a table.

The tags are always lower-case and each word of the object name is capitalized. Spaces and underscores are not used.

This naming convention is often used within the Microsoft Access community, and is standard in Visual Basic programming, but is not widely used elsewhere.

Hungarian notation (named after Charles Simonyi's native country) breaks down object names into the following elements:

[prefix(es)][tag]BaseName[Suffix/Qualifier]

The elements of the naming convention are described in the following table.

Component Description Example
Prefix(es) A lowercase letter that adds extra information to the tag p for Public variable
Tag A three-letter sequence indicating the object type tbl for table
BaseName A word or two describing the object. If several words are used, each starts with a capital letter, and there are no spaces between them OutlookContacts – contacts imported from Outlook
Suffix (RVBA), Qualifier (LNC) A word giving more specific information about an object ByDate – the data is sorted by date


The Basic LNC Object Prefixes
Object Tag
Incomplete objects, backup objects, or objects that are under development _ or – (In Access 2000 and later, dashes sort to the beginning of the database object list.)
Hidden system objects zh
Displayed system objects zs
Programmatically created temporary objects zt
Backup copies of objects, for later copying or reuse zz


The Basic LNC Variable Prefixes
Variable Type Tag
Local variable [no prefix]
Local static variable s
Module-level variable m
Public variable in a form or report module p
Public variable declared in the Declarations section of a standard module g


The Basic LNC Database Object Tags
Object Tag
Class module cls
Form frm
Form (dialog) fdlg
Form (menu) fmnu
Form (message) fmsg
Form (subform) fsub
Macro mcr
Module bas
Query (any type) qry
Query (append) qapp
Query (crosstab) qxtb
Query (data definition) qddl
Query (delete) qdel
Query (form filter) qflt
Query (lookup) qlkp
Query (make-table) qmak
Query (select) qry (or qsel)
Query (SQL pass-through) qspt
Query (union) quni
Query (update) qupd
Report rpt
Report (subreport) rsub
Table tbl
Table (attached dBASE) tdbf
Table (attached Excel) txls
Table (attached FoxPro) tfox
Table (attached Lotus) twks
Table (attached ODBC) todb
Table (attached Paradox) tpdx
Table (attached SQL Server) tsql
Table (attached text) ttxt
Table (lookup) tlkp


The LNC Table Field Tags
Object Tag
Autonumber (random non-sequential) idn
Autonumber (replication ID) idr
Autonumber (sequential) ids
Binary bin
Byte byt
Currency cur
Date/Time dtm
Double dbl
Hyperlink hlk
Integer int
Long lng
Memo mem
OLE ole
Single sng
Text (character) chr
Yes/No (Boolean) ysn


The LNC Tags for VBA Variables
Object Tag
Boolean bln
CommandBar cbr
Control (generic; useful when cycling through controls on a form or report) ctl
Currency cur
Database dbs
Double dbl
Form frm
Integer int
Long lng
QueryDef qdf
Report rpt
Single sng
Snapshot snp
String str
Table tbl
Type (user-defined) typ
Variant var


The LNC Tags for Form and Report Controls (may also be used in code referencing controls)
Object Tag
Attachment att
Bound object frame frb
Chart (graph) cht
Check box chk
Combo box cbo
Command button cmd
Custom control ocx
Frame fra
Hyperlink hlk
Image img
Label lbl
Line lin
List box lst
Option button opt
Option group grp
Page (on a Tab control) pge
Page break brk
Rectangle (shape) shp
Subform/report sub
Tab control tab
Text box txt
Toggle button tgl
Unbound object frame fru


Some Typical LNC Names for Database Objects, Controls and Variables
Object/variable name LNC naming elements Description
tblEmployees tag + base name A table of employee data
qupdSales tag + base name A query that updates sales data
fsubDayMax tag + base name + qualifier A subform that shows the maximum day
intLines tag + base name An Integer variable to hold a value representing the number of lines in a Word table
curSales tag + base name A Currency variable holding a Sales value
pstrForm prefix + tag + base name A public String variable holding a form name
zztblContacts prefix + tag + base name A backup Contacts table, for copying and filling with imported data

This article is taken from Helen Feddema's book, Expert One-on-One Microsoft Access Application Development, Wiley, ISBN 0-7645-5904-4, with some modifications.


Helen Feddema 21:56, 3 August 2007 (UTC)