Class naming

From OpenPetra Wiki
Jump to navigation Jump to search

Introduction and Background

All C# Class Names in openPETRA start with the prefix 'T'.

This has historical, but also practical reasons.

The 'T' prefix stems from the time when the development of the ancestor application of openPETRA was begun in the programming language 'Delpi.NET', which is a kind of Object Pascal ported to the .NET framework. The naming conventions of Delphi.NET (and its ancestor Delphi) include the 'T' prefix for Class Names. The reason that is given for having the 'T' prefix is that it stands for 'Type'. Also, Delphi.NET naming conventions have other prefixes, such as 'F' for 'Field' for a Class Field.

When converting the source code to C# we could have dropped the 'T' prefix for Class Names. However, we found it helpful to keep it because it makes for easy distinction between Classes of openPETRA and other Classes (be it of the .NET Framework or of other external libraries) - if a Class Name starts with the prefix 'T' and is followed by another captial letter then it is very likely a Class that belongs to openPETRA.

N.B.: We also kept the 'F' prefix for Class Fields and the 'A' prefix for Method Arguments (which we introduced ourselves) from our Delphi.NET times. They make for good readability (once one is used to them, of course).

Reasons for dropping the 'T' Class Name Prefix

  • Prefixes and postfixes, as well as Hungarian notation, are usually not used in C# code. (Exception: Hungarion notation is often used for WinForms Controls, [e.g. 'TextBox txtMyTextBox']).
  • Prefixes and postfixes, as well as hungarian notation, are not used in the .NET Framework's Classes, Properties, and Events.
    • However, that can be seen as a reason to not drop the 'T' Class Name prefix (see paragraph above)...
  • Contributors to openPETRA need to get used to the prefix.


Decision

TODO