Class Naming
- Written in PascalCase (capitalizing the first letter of each word).
- Generally written as a nouns that represent objects or entities.
- Example:
Player
,NPC
,Weapon
- Example:
- For classes that define specific behaviors or actions, write as a verb
- Example:
MoveLeftRight
,JumpHandler
- Example:
Creational Patterns
These patterns are designed to deal with the creation of objects, how and where an object is made.
Category | Type | Prefix | Suffix | Example Name | Notes |
---|---|---|---|---|---|
Script | Factory | - | Factory | EnemyFactory | Responsible for creating instance of a general type of object based on logic, without specifying exact details of each object. |
Script | Object Pool | - | Pool | EnemyPool | Manages a pool of reusable objects to optimize performance and resource usage. |
Script | Prototype | - | Prototype | EnemyPrototype | Creates new objects by copying existing ones, useful for generating similar objects efficiently. |
Script | Spawner | - | Spawner | EnemySpawner | Manages the creation and placement of objects, often used to control dynamic object generation in games. |
Script | Singleton | S | - | SDatabaseConnection | Implements the Singleton design pattern, ensuring only one instance of the class exists. |
Structural Patterns
These patterns are built to show the relationships between entities.
Category | Type | Prefix | Suffix | Example Name | Notes |
---|---|---|---|---|---|
Script | Component | - | Component | HealthComponent | Represents a part or module that can be attached to game objects. |
Script | Decorator | - | Decorator | PlayerDecorator | Enhances or adds functionality to existing classes or components. |
Script | Flyweight | - | Flyweight | BulletFlyweight | Reduces memory usage by sharing common data among similar objects, useful for managing large numbers of similar objects efficiently. |
Script | Service | - | Service | AudioService | Provides specific services or utilities, often to decouple functionality. |
Script | UI Element | UI | - | UIInventory , UIStartButton | Used for classes that manage UI elements. |
Behavioral Patterns
These patterns are designed to deal with how objects communicate with each other.
Category | Type | Prefix | Suffix | Example Name | Notes |
---|---|---|---|---|---|
Script | General | - | - | Tree , Lamp , Box | Basic MonoBehaviour classes used for simple, one-off game objects. These typically have no specific prefix or suffix. |
Script | Abstract Class | - | Base | CharacterBase | Used for abstract or foundational classes that are not instantiated directly but serve as base classes for inheritance. |
Script | Behaviour | - | Behaviour | AIBehaviour | Defines specific behaviors or actions in the context of game objects. |
Script | Command | - | Command | MoveCommand | Encapsulates actions as objects, making it easy to manage, undo, or repeat them. Useful for things like undo functionality and command history. |
Script | Controller | - | Controller | PlayerController | Manages input and interaction logic for game objects. |
Script | Event | - | Event | GameEvent | Represents events that can be triggered and handled in an event-driven system. |
Script | Interface | I | - | IDamageable | Defines a contract for classes; the I prefix is sometimes used to denote interfaces. |
Script | Manager | - | Manager | GameManager | Manages game-wide logic or specific aspects of the game, like audio or input. They are often singletons but not always. |
Script | Observer | - | Observer | ScoreObserver | Notifies subscribed objects when a change occurs. Useful for event-driven systems where multiple components need to react to changes. |
Script | ScriptableObject | - | Data | PlayerData | Used to create assets that hold data; the Data suffix indicates that the object is used for storing data. |
Script | State | - | State | PlayerState | Represents a particular state or condition within a state machine. |
Script | Strategy | - | Strategy | MovementStrategy or IMovementStrategy | Represents a strategy or algorithm used by a class or component. Strategy classes are typically Interfaces. |
Script | System | - | System | CombatSystem | Represents large-scale systems that manage complex logic or workflows. |
Script | Utility/Helper | - | Utility , Helper | MathUtility , StringHelper | Provides utility functions or methods, often static and used across various parts of the code. |
Inclusive Word Choice:
The following provides guidance and suggestions to help you choose words and names that are respectful and appropriate for all situations and audiences and be a more effective communicator.
Word Name | Alternative Word Name |
---|---|
Blacklist | deny list, block list, exclude list, avoid list, unapproved list, forbidden list, permission list |
Whitelist | allow list, include list, trust list, safe list, prefer list, approved list, permission list |
Master | primary, source, controller, template, reference, main, leader, original, base |
Slave | secondary, replica, agent, follower, worker, cluster node, locked, linked, synchronized |