Table of Contents

A clear, consistent naming scheme not only improves readability but also makes collaboration easier. When it comes to naming object-orientated classes, following a proper convention helps developers quickly understand what a class represents and how it’s meant to be used.

In C# class names follow PascalCase and should typically be written as nouns, since a class usually represents an object, concept, or entity in your system. Depending on the type of class, a suffix may also be added to clarify its role. These suffixes often correspond to design pattern categories, such as Creational, Structural, or Behavioral, which provide a shared vocabulary for organizing code.

By combining consistent casing, noun-based naming, and meaningful suffixes tied to pattern types, your class names become self-explanatory. This reduces guesswork, speeds up onboarding for new developers, and enforces a style that keeps your project clean and maintainable over time.

Below, is a break down of some common class naming schemes for each major pattern category and highlight typical suffixes or naming practices that make a class’s purpose clear at a glance.

Creational Patterns

Creational patterns deal with object creation. Classes in this category define how objects are instantiated, often abstracting away complex creation logic. They help ensure that objects are created in a controlled, flexible, and reusable way.

TypePrefixSuffixExample NameNotes
FactoryFactoryEnemyFactoryResponsible for creating instance of a general type of object based on logic, without specifying exact details of each object.
Object PoolPoolEnemyPoolManages a pool of reusable objects to optimize performance and resource usage.
PrototypePrototypeEnemyPrototypeCreates new objects by copying existing ones, useful for generating similar objects efficiently.
SpawnerSpawnerEnemySpawnerManages the creation and placement of objects, often used to control dynamic object generation in games.
SingletonSSDatabaseConnectionImplements the Singleton design pattern, ensuring only one instance of the class exists.

Structural Patterns

Structural patterns focus on how classes and objects are organized and how they relate to one another. Classes in this category define relationships, hierarchies, or compositions to make the system more modular and maintainable.

TypePrefixSuffixExample NameNotes
ComponentComponentHealthComponentRepresents a part or module that can be attached to game objects.
DecoratorDecoratorPlayerDecoratorEnhances or adds functionality to existing classes or components.
FlyweightFlyweightBulletFlyweightReduces memory usage by sharing common data among similar objects, useful for managing large numbers of similar objects efficiently.
ServiceServiceAudioServiceProvides specific services or utilities, often to decouple functionality.
UI ElementUIUIInventory

UIStartButton
Used for classes that manage UI elements.

Behavioral Patterns

Behavioral patterns define how objects interact and communicate with each other, focusing on algorithms, workflows, and responsibilities. Classes in this category often encapsulate actions or strategies that can vary independently from the objects that use them.

TypePrefixSuffixExample NameNotes
GeneralTree

Lamp

Box
Basic MonoBehaviour classes used for simple, one-off game objects. These typically have no specific prefix or suffix.
Abstract ClassBaseCharacterBaseUsed for abstract or foundational classes that are not instantiated directly but serve as base classes for inheritance.
BehaviourBehaviourAIBehaviourDefines specific behaviors or actions in the context of game objects.
CommandCommandMoveCommandEncapsulates actions as objects, making it easy to manage, undo, or repeat them. Useful for things like undo functionality and command history.
ControllerControllerPlayerControllerManages input and interaction logic for game objects.
EventEventGameEventRepresents events that can be triggered and handled in an event-driven system.
InterfaceIIDamageableDefines a contract for classes; the I prefix is sometimes used to denote interfaces.
ManagerManagerGameManagerManages game-wide logic or specific aspects of the game, like audio or input. They are often singletons but not always.
ObserverObserverScoreObserverNotifies subscribed objects when a change occurs. Useful for event-driven systems where multiple components need to react to changes.
ScriptableObjectDataPlayerDataUsed to create assets that hold data; the Data suffix indicates that the object is used for storing data.
StateStatePlayerStateRepresents a particular state or condition within a state machine.
StrategyStrategyMovementStrategy 

or 

IMovementStrategy
Represents a strategy or algorithm used by a class or component. Strategy classes are typically Interfaces.
SystemSystemCombatSystemRepresents large-scale systems that manage complex logic or workflows.
Utility/HelperUtility

Helper
MathUtility

StringHelper
Provides utility functions or methods, often static and used across various parts of the code.

These examples represent just a small selection of common class naming conventions tied to design pattern categories, but they provide a solid starting point. By following these basic guidelines, using PascalCase, nouns, and meaningful prefixes/suffixes, you can create class names that clearly communicate purpose, improve readability, and make your codebase easier to navigate. As you gain experience, you can expand and adapt these conventions to suit the specific needs of your projects and team.

Categorized in:

Tagged in: