Method Naming Patterns
Public API Methods
| Pattern | Purpose | Example |
|---|---|---|
check_* | Public entry points for spell checking | check(), check_batch(), check_async() |
validate_* | Internal validation methods | validate(), validate_sentence() |
get_* | Data retrieval methods | get_syllable_frequency(), get_word_pos() |
is_* | Boolean validation checks | is_valid_syllable(), is_valid_word() |
has_* | Existence checks (dictionary membership) | has_syllable(), has_word() |
create_* | Factory methods | create_default(), create_fast() |
build_* | Builder pattern methods | build(), build_from_corpus() |
Distinction: is_* vs has_*
is_valid_*(): May perform validation beyond existence check (e.g., rule validation)has_*(): Pure existence check - only tests dictionary membership
Distinction: check_* vs validate_*
check_*(): High-level public API (returnsResponseobjects)validate_*(): Lower-level internal methods (returnsList[Error])
Class Naming Patterns
| Pattern | Purpose | Example |
|---|---|---|
*Validator | Validation logic | SyllableValidator, WordValidator, ContextValidator |
*Provider | Data access abstraction | DictionaryProvider, SQLiteProvider |
*Checker | Analysis/checking components | NgramContextChecker, SemanticChecker |
*Factory | Object creation | ComponentFactory, POSTaggerFactory |
*Config | Configuration classes | SpellCheckerConfig, SymSpellConfig |
*Strategy | Strategy pattern implementations | ValidationStrategy, ToneValidationStrategy |
*Error | Error types | SyllableError, WordError, ContextError |
Variable Naming
General Rules
- Use
snake_casefor variables and functions - Use
PascalCasefor classes - Use
UPPER_SNAKE_CASEfor constants - Use descriptive names that indicate purpose
Specific Patterns
| Context | Pattern | Example |
|---|---|---|
| Syllable data | syllable_* | syllable_frequency, syllable_cache |
| Word data | word_* | word_frequency, word_errors |
| Configuration | *_config | symspell_config, ngram_config |
| Cache instances | *_cache | syllable_cache, bigram_cache |
| Thresholds | *_threshold | bigram_threshold, confidence_threshold |
| Counts/sizes | *_count, *_size | syllable_count, cache_size |
| Flags | use_*, enable_*, is_* | use_phonetic, enable_caching, is_valid |
Avoid Ambiguous Names
| Avoid | Prefer | Reason |
|---|---|---|
data | syllable_data, word_frequencies | Too generic |
result | validation_result, check_response | Unclear what type |
temp | cached_value, intermediate_score | Non-descriptive |
val | value, syllable_value | Abbreviated |
idx | index, word_index | Abbreviated |
cb | callback, on_complete | Abbreviated |
Private Method Naming
Use single underscore prefix for all private methods:Parameter Naming
Boolean Parameters
Use positive names that indicate the enabled state:Configuration Parameters
Match the configuration class field names:File Naming
| Type | Pattern | Example |
|---|---|---|
| Module | snake_case.py | spell_checker.py, ngram_context.py |
| Test file | test_*.py | test_spell_checker.py |
| Config file | *_config.py or *_configs.py | algorithm_configs.py |
| Interface | interfaces.py or base.py | providers/base.py |
| Constants | constants.py | training/constants.py |