A case for using verbs in class names, challenging the common OOP heuristic that class names should only be nouns. Three specific patterns are explored: Commands and Events (e.g., AttackEnemy, EnemyWasDefeated), Specifications (e.g., CustomerIsPremium, OrderIsReadyForShipment), and domain Exceptions (e.g., OrderShipmentHasFailed). The argument is that verb-inclusive names create self-documenting, sentence-like code that eliminates mental translation between natural language and code structure.
30 Impressions