Naming Conventions¶
TL;DR¶
This document provides some guidelines for contributors.
General¶
Every name and naming pattern should tell your reader what something does - not where it lives.
Avoid¶
These descriptors are weak and underspecified. Please avoid them:
Term |
Smell |
Use Instead |
|---|---|---|
|
Weak; everything ultimately “gets” something |
Use a noun: |
|
Weak; everything is ultimately “core” depending on the viewpoint |
Name by purpose: |
|
A classic dumping ground |
Name by function: |
|
A classic dumping ground |
Be specific: |
|
Vague |
Name the actual abstraction |
|
Weak |
Split into meaningful modules |
|
A classic dumping ground and a God object |
Use specific nouns: |
|
Vague |
Name the actor or action: |
|
Weak |
Use a specific verb |
|
Vague |
|
|
Vague |
Name what the data represents |
Verb Prefixes¶
For action-oriented names (functions, methods), use verbs that convey a specific intent:
Verb |
Meaning |
Example |
|---|---|---|
|
Retrieve from external source (API, network) |
|
|
Load from local source (file, memory) |
|
|
Derive a value through calculation |
|
|
Convert raw, unstructured data to a (more) structured form |
|
|
Construct a complex object step by step |
|
|
Check correctness, return bool or raise |
|
|
Send an event or signal outwards |
|
|
Record a state change for later use |
|
|
Convert a reference to a concrete value |
|
|
Pull specific data from a larger structure |
|
Accessor Patterns¶
Pattern |
When |
Example |
|---|---|---|
|
Operations that are lightweight, cached, or computed once |
|
|
Returning state, no side effects |
|
|
Expensive calculations |
|
|
Involves network I/O |
|
If something accesses a network or disk, use a verb. If it returns a state, use a noun.
Event Classes (DDD Patterns)¶
Events represent something that has happened. Name them in the past tense:
Pattern |
Example |
|---|---|
|
|
|
|
Examples:
class SessionStarted(BaseModel): ...
class IterationCompleted(BaseModel): ...
class ValidationCompleted(BaseModel): ...
class TaskFailed(BaseModel): ...
Avoid: SessionStartData, IterationEndData, CompletedData
Class Suffixes¶
Type |
Suffix |
Examples |
|---|---|---|
Backends |
|
|
Exceptions |
|
|
Results |
|
|
Messages |
|
|
Configs and settings |
|
|
Protocols |
(no suffix) |
|
Detectors and analyzers |
|
|
Binary Names¶
Prefix |
Use For |
Example |
|---|---|---|
|
State checks |
|
|
Possession and inclusion checks |
|
|
Capability and potential checks |
|
|
Policy and behavior decisions |
|
Avoid: check_* returning a bool (instead use check_* for void functions that raise errors)
Module Names¶
Pattern |
Meaning |
Example |
|---|---|---|
|
A specific single concept |
|
|
A concept and its role |
|
|
A process-oriented module |
|
Avoid: *_utils.py, *_helpers.py, *_common.py, core.py
Constant Names¶
# Module-level constants: SCREAMING_SNAKE with a Final type hint
DEFAULT_MAX_ITERATIONS: Final[int] = 5
DEFAULT_MODEL: Final[str] = "claude-sonnet-4-20250514"
# Private constants: underscore prefix
_MCP_TIMEOUT_MS: Final[int] = 30000
Test Names¶
# Class names: Test{ClassUnderTest}
class TestBudgetMeter:
# Method names: test_{behavior} or test_{method}_{scenario}
def test_tracks_token_usage(self): ...
def test_exceeded_when_over_limit(self): ...
# Async names: same pattern
async def test_streams_backend_messages(self): ...
Avoid: test_1, test_basic, test_it_works
Additional Tips¶
No
get_*use noun methods or properties
No
core,utils,helpersname by purpose
No
*DataEvents are past facts
SessionStarted,TaskCompleted,RequestRefused
Verbs convey I/O
fetch_*(network),read_*(file),compute_*(CPU)
Nouns convey roles
*Backend,*Result,*Error,*Message
Booleans are questions
is_*,has_*,can_*,should_*