Class Naming Patterns in Software Architecture
March 17th, 2026 2:09 PM Mr. Q Categories: Programming
Why Class Names Matter
Class names are more than labels. They tell you what a class is responsible for, how long it should live, how much authority it has in the system, and how other parts of the code should interact with it.
When naming classes, the goal is not just consistency. The goal is clarity. A good class name makes the architecture easier to read before anyone even opens the file.
For systems like robots, game engines, WordPress plugins, and web applications, naming patterns can help separate runtime state, business logic, orchestration, persistence, and external integrations.
Class Naming Pattern Reference Table
| Pattern | What It Means | Typical Use Case | Lifetime / Scope | Example |
|---|---|---|---|---|
| Session | Represents one active interaction, run, connection, or temporary working state | A robot control run, logged-in user session, game match, editor session | Short-lived | RobotSession, GameSession |
| Service | Encapsulates business logic or operational logic | Navigation rules, category processing, command validation, calculations | Medium | NavigationService, CategoryService |
| Manager | Coordinates multiple related objects, resources, or processes | Sensor coordination, bullet lists, task pools, lifecycle tracking | Medium to long-lived | SensorManager, BulletManager |
| System | A core subsystem that runs continuously or participates in the main architecture loop | Physics, rendering, collision, input, monitoring | Long-lived | PhysicsSystem, CollisionSystem |
| Factory | Creates objects and hides construction complexity | Commands, enemies, controllers, config-driven object creation | Usually stateless | CommandFactory, EnemyFactory |
| AppContext | Shared application context or dependency container | Shared config, services, runtime environment, common references | Application-wide | RobotAppContext, GameAppContext |
| Controller | Entry point for outside requests or commands | REST requests, UI events, command entry, device actions | Short to medium | MovementController, ApiController |
| Provider | Supplies data, hardware input, or external resources | I2C access, ultrasonic readings, configuration lookup, remote data | Medium | I2CProvider, ConfigProvider |
| Repository | Handles persistence and retrieval of stored data | Posts, tasks, settings, saved state, logs | Medium | PostRepository, TaskRepository |
| Engine | The central runtime driver or update loop | Main game loop, robot loop, simulation engine | Long-lived | GameEngine, RobotEngine |
| Handler | Processes one specific event, command, or case | Collision handling, error handling, command handling | Short | CollisionHandler, CommandHandler |
| Adapter | Converts one interface or format into another | Pi-to-Arduino protocol mapping, third-party wrapper, legacy bridge | Usually stateless | ArduinoAdapter, ApiAdapter |
| Facade | Simplifies access to a complex subsystem | A single interface over motors, sensors, and state logic | Medium | RobotFacade, SitemapFacade |
| Builder | Constructs something step by step | Packet building, path building, complex config objects | Short | PacketBuilder, PathBuilder |
| Strategy | Encapsulates a swappable algorithm or behavior | Movement styles, pathfinding modes, scoring rules | Usually stateless | TurnStrategy, PathStrategy |
| Registry | Central lookup table for services, objects, or plugins | Named service registration, command lookup, plugin maps | App-wide | ServiceRegistry, CommandRegistry |
| Coordinator | Orchestrates a multi-step workflow across components | Startup sequence, navigation flow, sync workflow | Medium | NavigationCoordinator, SyncCoordinator |
| Dispatcher | Routes commands, events, or messages to the correct target | Event bus, command routing, message fan-out | Medium | EventDispatcher, CommandDispatcher |
| State | Represents one explicit state in a state machine | Alive, dying, idle, moving, paused, connected | Short to medium | AliveState, IdleState |
| Middleware | Intercepts requests, messages, or processing pipelines | Logging, auth, filtering, validation, timing | Medium | AuthMiddleware, LoggingMiddleware |
| Client | Talks directly to an external service or system | REST APIs, hardware modules, AI services, network endpoints | Medium | OpenAIClient, MotorClient |
| Config | Holds structured configuration values and rules | App settings, device thresholds, feature flags | Long-lived | RobotConfig, SensorConfig |
| Policy | Encodes a rule set or decision standard | Retry rules, safety rules, permissions, movement constraints | Usually stateless | RetryPolicy, SafetyPolicy |
| Validator | Verifies input, state, or payload correctness | Command validation, config validation, sensor range checks | Usually stateless | CommandValidator, ConfigValidator |
| Resolver | Determines the correct value, target, or dependency at runtime | Route resolution, device resolution, command mapping | Short | RouteResolver, DeviceResolver |
| Store | Maintains mutable shared state, often in UI or app state systems | Frontend state, dashboard state, current robot status cache | Medium to long-lived | RobotStore, UiStore |
| Cache | Temporarily stores expensive results for faster access | WordPress query cache, sensor smoothing cache, compiled output | Medium | PostCache, SensorCache |
How to Choose the Right Pattern
Use Session when the class represents one active run or temporary interaction.
Use Service when the class performs meaningful application logic but does not need to own the entire system.
Use Manager when the class supervises a group of related things.
Use System when the class is a major subsystem that runs as part of the architecture itself.
Use Factory when the main responsibility is creating objects.
Use AppContext when the class holds shared application references, dependencies, configuration, or environment objects.
Use Controller when the class receives outside input and hands work off to internal logic.
Use Provider when the class fetches, reads, or supplies information from a source such as hardware, config, or an API.
Use Repository when the class reads or writes stored data.
Use Engine when the class is effectively the application loop or runtime driver.
Use Handler when one focused class handles one specific event or command.
Use Adapter when one class converts an incompatible interface into the one your app expects.
Use Facade when you want a simpler public surface over a more complicated subsystem.
Use Builder when object creation happens in steps.
Use Strategy when you want multiple interchangeable behaviors under the same interface.
Use Registry when the job is to register and look up things by key.
Use Coordinator when the main job is guiding a process across multiple components.
Use Dispatcher when messages or commands need to be routed to the right destination.
Use State when you are modeling behavior based on explicit states.
Use Middleware when you need a processing layer between the input and final destination.
Use Client when the class actively communicates with another system.
Fast Naming Guide
A class that creates things should usually be a Factory or Builder.
A class that talks to hardware or remote APIs should usually be a Provider or Client.
A class that stores and retrieves data should usually be a Repository.
A class that coordinates multiple moving parts should usually be a Manager or Coordinator.
A class that performs business rules should usually be a Service.
A class that runs continuously in the architecture should usually be a System or Engine.
A class that receives external commands should usually be a Controller.
A class that exposes a simplified interface over many internals should usually be a Facade.
Good Examples by Project Type
Robot Build Examples
RobotSession
Tracks one active robot runtime session, start state, stop state, and temporary data.
NavigationService
Contains path logic and movement decisions.
SensorManager
Coordinates multiple ultrasonic sensors and shared reading flow.
BalanceSystem
Runs continuously to maintain orientation and safety.
CommandFactory
Creates command packets from high-level movement requests.
RobotAppContext
Holds shared config, providers, services, and active references.
I2CProvider
Wraps low-level I2C communication.
SafetyPolicy
Defines movement limits and fall-protection rules.
Game Engine Examples
GameSession
Represents one match or play session.
PhysicsService
Contains reusable motion calculations.
BulletManager
Tracks bullets, lifetimes, cleanup, and pooling.
CollisionSystem
Runs collision checks as part of the game loop.
EnemyFactory
Creates enemy objects from type definitions.
GameEngine
Runs the main loop and update cycle.
AliveState
Represents behavior while an entity is alive.
RenderAdapter
Translates engine objects into render calls.
WordPress Plugin Examples
CategoryService
Contains category-related business logic.
PostRepository
Handles post retrieval and caching strategy.
SitemapFacade
Provides one simple public interface for generating sitemap-style output.
CacheManager
Coordinates cache creation, invalidation, and refresh.
PluginAppContext
Holds services, settings, and shared plugin dependencies.
SettingsController
Processes admin settings input.
OptionsProvider
Supplies plugin options from WordPress settings.
ValidationMiddleware
Runs checks before processing updates.
Common Mistakes to Avoid
Using Manager for Everything
Manager is one of the most overused class names. It often becomes vague and hides unclear responsibility.
If the class contains rules, call it a Service.
If it runs continuously, call it a System.
If it coordinates a workflow, call it a Coordinator.
If it stores data, call it a Repository.
Using Service as a Dumping Ground
A Service should still have a focused responsibility. If it starts talking to hardware, storing data, validating input, and coordinating workflows all in one file, it probably needs to be split up.
Calling Small Helpers a System
System should feel important, central, and architectural. If the class just formats a value or performs one local operation, System is too big a name.
Using AppContext as a Global Junk Drawer
AppContext should not become a dumping ground for random references. It should hold only shared dependencies and environment-level items that truly need broad access.
Recommended Naming Rule of Thumb
If you can describe the class job in one sentence, the name is probably close to correct.
If the class name sounds important but the implementation is small, the name is probably too big.
If the class does several different things that point to different naming patterns, it likely needs to be split into multiple classes.
Final Takeaway
These naming patterns are best treated as architectural signals.
They help answer questions like:
What does this class own?
Who should call it?
How long should it live?
Is it core logic, external access, orchestration, or storage?
Should it be reused, replaced, mocked, or extended?
When used consistently, names like Session, Service, Manager, System, Factory, Controller, Provider, Repository, and Coordinator make a codebase much easier to navigate and maintain.
Quick Summary Block
Session is for temporary runtime interactions.
Service is for business logic.
Manager is for coordinating related objects.
System is for core architectural subsystems.
Factory is for object creation.
AppContext is for shared application-wide references.
Controller is for external input.
Provider is for supplying data or external resources.
Repository is for persistence.
Engine is for runtime loops.
Handler is for focused event processing.
Adapter is for interface conversion.
Facade is for simplifying a complex subsystem.
Builder is for step-by-step construction.
Strategy is for interchangeable behavior.
Coordinator is for multi-step orchestration.
Dispatcher is for routing.
State is for state-machine behavior.
Middleware is for intercepting pipelines.
Client is for external communication.
Featured Snippet Paragraph
Class naming patterns like Session, Service, Manager, System, Factory, Controller, Provider, and Repository help define responsibility, scope, and architecture in a codebase. Session usually represents temporary runtime state, Service contains business logic, Manager coordinates related objects, System runs as a core subsystem, Factory creates objects, Controller handles external input, Provider supplies data or hardware access, and Repository manages persistence. Consistent naming makes software easier to read, maintain, and scale.