Game Development Reference
In-Depth Information
Note
There may be times when you need to deviate from the “best practice” naming conventions, espe-
cially when working with legacy components that expect traditionally named symbols; do so spar-
ingly and only when absolutely necessary.
Naming Classes
When naming classes, the standard is to use Pascal case. Additionally, classes
should be named using a noun or a noun phrase. Finally, never use an underscore
in a class name either.
One traditional style common among many developers is to use prefixes such as
cFileStream or CFileStream . Never use prefixes anywhere with the exception of
interfaces. The proper naming would be FileStream in this example.
Abbreviations should be used only when absolutely necessary. They cause confusion
when reading code, and break from the standards used in the class framework.
Derived classes should be named in a compounded fashion where the second half
of the name is the base class name. An example would be the derived class
SystemException , which inherits from the base class Exception . This guideline is to
be used at your discretion, as derived class names should only be compounded
when it makes sense to do so.
Example:
public class SimpleException : Exception
{
}
Naming Interfaces
When naming interfaces, the standard is to use Pascal case. Additionally, interfaces
should be named using a noun or noun phrase, or an adjective that describes its
behavior. Finally, never use an underscore in a class name either.
Interfaces should always be prefixed with I , as in IBaseController . This is the only
situation where an identifier should be prefixed in the .NET class framework.
When a class implements an interface, the naming should only differ by the prefix
I on the interface name.
Abbreviations should be used only when absolutely necessary. They cause confusion
when reading code, and break from the standards used in the .NET Class Framework.
 
Search Nedrilad ::




Custom Search