Delphi - Component Naming Conventions / Branding

I discuss programming naming conventions elsewhere. This page discusses how to name objects and components you create. In general, you should add a 2- or 3-letter prefix to the code you generate that identifies who you are. Frequently, this will identify your company. Besides simply branding your work, the main purpose of this is to reduce naming conflicts.

Some of the newer languages require the name of the library (object file) be typed before every instance of a function defined in the library.

Thankfully, Delphi 5 does not require that nonsense .. but it does allow it when 2 units (the Delphi version of libraries and object files) contain items with the same name.

Over a number of years, I have come up with *a* scheme for naming things that I plan to reuse in multiple projects.

Some of my older code does not follow these guidelines.

The Problem | Units | Global Constants and Functions | Object Names | Single Global Objects

The Problem

Delphi does not allow a unit and a global identifier (variable, function, object, ...) to have the same name. This is necessary because any global identifier can be qualified by the name of the unit it is defined in. When a unit (file) simply defines types, this is not a problem - you simply prefix the unit name with the letter 'T'. The problem arises when the unit also defines a global instance of the object .. and I want all 3 names to be similar. In those cases, I prefer to add an underscore between the branding identifier and the object identifier. I tried placing the underscore after the 'T'. However, when the component is placed on a form, Delphi creates the default name by dropping the initial-T and adding a number. and I don't want variable names to start with an underscore.

However, I always use an underscore before a trailing branding identifier. See Global Constants and Functions (below) for examples.


Most languages provide a way to package code so that it is relatively easy to use it in multiple programs. The terminology and specifics vary from one language to another, but the general purpose is the same. The Delphi unit is compiled from several source files - all of which have the same name, but different extensions. This is the name that must be included in the Uses clause.

While it is possible to distribute units (name.dcu) without any source, Delphi has made this difficult. Unfortunately, a different version of the dcu file is required for each version of Delphi.

I name the units by using a 2-letter prefix.

Global Constants and Functions

For constants, and many global functions, I use a suffix. From unit mcExtras, sometimes I use a prefix. I use the suffix styling when I am more likely to type something logical and want the built-in help to suggest appropriate options, and the prefix styling for more complicated names.

Object Names

Typically, I will use a prefix for object names. (A component is simply an object that can be selected from a toolbar.)

Single Global Objects

There are many times that I want a single, globally available object. For these, I prefer the mc_ styling.

From unit mcExtras,

mc_LogFiles is one of the exceptions. In this case, I placed the underscore in the unit name / filename and used a global variable (instead of a function) to access it. I haven't decided which method to access the object is "best", but I have decided to use the underscore for the objects and to omit it for the class.

Author: Robert Clemenzi
URL: http:// / Languages / Delphi / ComponentNamingConventions.html