Leszynski naming convention

Last updated

The Leszynski naming convention (or LNC) is a variant of Hungarian notation popularized by consultant Stan Leszynski specifically for use with Microsoft Access development. [1] Although the naming convention is nowadays often used within the Microsoft Access community, and is the standard in Visual Basic programming, it is not widely used elsewhere.

Contents

The conventions are derived from an earlier set of conventions, the Leszynski/Reddick naming conventions, originally developed in 1992 by Greg Reddick. Eventually, Leszynski and Reddick had different ideas about how the conventions should be developed, and split into two separate sets of conventions, the other being the RVBA Conventions.

As in all Hungarian notations, it uses prefixes (called tags) to indicate the type of objects and database development fields. The general structure of Hungarian notation (named after Charles Simonyi's native country) is to break down object names into the following elements: [prefix(es)][tag]BaseName[Suffix/Qualifier] The tags are lower case and the object name is camel case. Spaces and underscores are not used.

Advantages

Since the Leszynski naming convention is a special form of Hungarian notation the same general advantages also apply to the Leszynski convention.

The 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.

Disadvantages

Elements

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

ComponentDescriptionExample
Prefix(es)A lowercase letter that adds extra information to the tagp for Public variable
TagA three-letter sequence indicating the object typetbl for table
BaseNameA word or two describing the object. If several words are used, each starts with a capital letter, and there are no spaces between themOutlookContacts – contacts imported from Outlook
Suffix (RVBA), Qualifier (LNC)A word giving more specific information about an objectByDate – the data is sorted by date

The Basic LNC Object Prefixes

ObjectTag
Incomplete objects, backup objects, or objects that are under development_ or – (In some versions of Access, dashes sort to the beginning of the database object list.)
Hidden system objectszh
Displayed system objectszs
Programmatically created temporary objectszt
Backup copies of objects, for later copying or reusezz

The Basic LNC Variable Prefixes

Variable TypeTag
Local variable[no prefix]
Local static variables
Module-level variablem
Public variable in a form or report modulep
Public variable declared in the Declarations section of a standard moduleg

The Basic LNC Database Object Tags

ObjectTag
Class modulecls
Formfrm
Form (dialog)fdlg
Form (menu)fmnu
Form (message)fmsg
Form (subform)fsub
Macromcr
Modulebas
Modulemod
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
Reportrpt
Report (subreport)rsub
Tabletbl
Middle Tabletrel
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
Pagespge

The LNC Table Field Tags

ObjectTag
Autonumber (random non-sequential)idn
Autonumber (replication ID)idr
Autonumber (sequential)ids
Binarybin
Bytebyt
Currencycur
Date/Timedtm
Doubledbl
Hyperlinkhlk
Integerint
Longlng
Memomem
OLEole
Singlesng
Text (character)chr
Yes/No (Boolean)ysn

The LNC Tags for VBA Variables

ObjectTag
Booleanbln
CommandBarcbr
Control (generic; useful when cycling through controls on a form or report)ctl
Currencycur
Databasedbs
Doubledbl
Formfrm
Integerint
Longlng
QueryDefqdf
Reportrpt
Singlesng
Snapshotsnp
Stringstr
Tabletbl
Type (user-defined)typ
Variantvar

The LNC Tags for Form and Report Controls

(may also be used in code referencing controls)
ObjectTag
Attachmentatt
Bound object framefrb
Chart (graph)cht
Check boxchk
Combo boxcbo
Command buttoncmd
Custom controlocx
Framefra
Hyperlinkhlk
Imageimg
Labellbl
Linelin
List boxlst
Option button (Radio Button)opt
Option groupgrp
Page (on a Tab control)pge
Page breakbrk
Rectangle (shape)shp
Subform/reportsub
Tab controltab
Text boxtxt
Toggle buttontgl
Buttonbtn
Unbound object framefru

Some Typical LNC Names for Database Objects, Controls and Variables

Object/variable nameLNC naming elementsDescription
tblEmployeestag + base nameA table of employee data
qupdSalestag + base nameA query that updates sales data
fsubDayMaxtag + base name + qualifierA subform that shows the maximum day
intLinestag + base nameAn Integer variable to hold a value representing the number of lines in a Word table
curSalestag + base nameA Currency variable holding a Sales value
pstrFormprefix + tag + base nameA public String variable holding a form name
zztblContactsprefix + tag + base nameA backup Contacts table, for copying and filling with imported data

Related Research Articles

Camel case Writing words with internal uppercase letters

Camel case is the practice of writing phrases without spaces or punctuation, indicating the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include "iPhone", "JavaScript", and "eBay". It is also sometimes used in online usernames such as "johnSmith", and to make multi-word domain names more legible, for example in advertisements.

Database Organized collection of data

A database is an organized collection of data, generally stored and accessed electronically from a computer system. Where databases are more complex they are often developed using formal design and modeling techniques.

Eiffel is an object-oriented programming language designed by Bertrand Meyer and Eiffel Software. Meyer conceived the language in 1985 with the goal of increasing the reliability of commercial software development; the first version becoming available in 1986. In 2005, Eiffel became an ISO-standardized language.

Microsoft Access Database manager that is part of the Microsoft Office package

Microsoft Access is a database management system (DBMS) from Microsoft that combines the relational Microsoft Jet Database Engine with a graphical user interface and software-development tools. It is a member of the Microsoft Office suite of applications, included in the Professional and higher editions or sold separately. It is also a member of the Microsoft 365 suite. Latest versions have more protections. A trial version of the software is available.

A relational database is a digital database based on the relational model of data, as proposed by E. F. Codd in 1970. A software system used to maintain relational databases is a relational database management system (RDBMS). Many relational database systems have an option of using the SQL for querying and maintaining the database.

SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data, i.e. data incorporating relations among entities and variables.

Hungarian notation is an identifier naming convention in computer programming, in which the name of a variable or function indicates its intention or kind, and in some dialects its type. The original Hungarian Notation uses intention or kind in its naming convention and is sometimes called Apps Hungarian as it became popular in the Microsoft Apps division in the development of Word, Excel and other apps. As the Microsoft Windows division adopted the naming convention, they used the actual data type for naming, and this convention became widely spread through the Windows API; this is sometimes called Systems Hungarian notation.

Object–relational database

An object–relational database (ORD), or object–relational database management system (ORDBMS), is a database management system (DBMS) similar to a relational database, but with an object-oriented database model: objects, classes and inheritance are directly supported in database schemas and in the query language. In addition, just as with pure relational systems, it supports extension of the data model with custom data types and methods.

In database systems, isolation determines how transaction integrity is visible to other users and systems. For example, when a user is creating a purchase order and has created the header, but not the purchase order lines, is the header available for other systems or users to see?

Data modeling

Data modeling in software engineering is the process of creating a data model for an information system by applying certain formal techniques.

A query plan is a sequence of steps used to access data in a SQL relational database management system. This is a specific case of the relational model concept of access plans.

A user-defined function (UDF) is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment.

In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation.

The object–relational impedance mismatch is a set of conceptual and technical difficulties that are often encountered when a relational database management system (RDBMS) is being served by an application program written in an object-oriented programming language or style, particularly because objects or class definitions must be mapped to database tables defined by a relational schema.

In computer science, a database cursor is a control structure that enables traversal over the records in a database. Cursors facilitate subsequent processing in conjunction with the traversal, such as retrieval, addition and removal of database records. The database cursor characteristic of traversal makes cursors akin to the programming language concept of iterator.

Borland Database Engine (BDE) is the Windows-based core database engine and connectivity software behind Borland Delphi, C++Builder, IntraBuilder, Paradox for Windows, and Visual dBASE for Windows.

Entity–attribute–value model (EAV) is a data model to encode, in a space-efficient manner, entities where the number of attributes that can be used to describe them is potentially vast, but the number that will actually apply to a given entity is relatively modest. Such entities correspond to the mathematical notion of a sparse matrix.

Semi-structured data is a form of structured data that does not obey the tabular structure of data models associated with relational databases or other forms of data tables, but nonetheless contains tags or other markers to separate semantic elements and enforce hierarchies of records and fields within the data. Therefore, it is also known as self-describing structure.

Apache Empire-db is a Java library that provides a high level object-oriented API for accessing relational database management systems (RDBMS) through JDBC. Apache Empire-db is open source and provided under the Apache License 2.0 from the Apache Software Foundation.

PL/SQL is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is available in Oracle Database, Times Ten in-memory database, and IBM DB 2. Oracle Corporation usually extends PL/SQL functionality with each successive release of the Oracle Database.

References

Part of this article is based on Helen Feddema's book, Expert One-on-One Microsoft Access Application Development, Wiley, ISBN   0-7645-5904-4.