Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add Ariel-Rodriguez/programming-skills --skill "ps-naming-as-design"
Install specific skill from multi-skill repository
# Description
Names must encode intent and constraints, not implementation. Use when reviewing vague or generic names.
# SKILL.md
name: ps-naming-as-design
description: Names must encode intent and constraints, not implementation. Use when reviewing vague or generic names.
severity: WARN
Naming As Design
Principle
Names are design decisions made visible. Every name reveals what you understand about the problem domain, the role of each component, and the boundaries between concepts.
Core insight:
- Good names make the design obvious
- Bad names reveal confused thinking
- When you can't name something clearly, the design needs work
When to Use
Use this pattern when:
- Reviewing any new code or APIs
- A function/variable is hard to name (signals design problem)
- Names include "Manager", "Handler", "Data", "Info", "Process"
- Names require explaining what they mean
Indicators you need this:
- Comments explaining what variables mean
- Generic names (data, item, value, result, temp)
- Names mixing abstraction levels (getUserFromDBAndFormat)
- Names that don't reveal intent (handle, process, do, manage)
Instructions
Name reveals purpose, not implementation
Names should tell you what and why, not how.
β Avoid implementation details:
arrayOfUsersβ data structure is obvious from usagegetUserFromDatabaseβ storage mechanism is internalparseJSONAndValidateβ combining unrelated concerns
β Reveal intent and role:
eligibleCandidatesβ tells you the selection criteriaauthenticatedUserβ tells you the authorization statevalidatedOrderβ tells you the business state
Name reveals constraints and invariants
Good names encode business rules and constraints.
Examples of constraint-encoding names:
NonEmptyStringvsstring- makes null handling explicitPositiveAmountvsnumber- encodes valid rangeAuthenticatedUservsUser- encodes state requirementUnvalidatedInputvsdata- signals trust boundary
Name forces single responsibility
If you can't name something without "And", "Or", "Manager", it's doing too much.
β Signals mixed responsibilities:
validateAndSaveβ two responsibilitiesUserManagerβ vague, does everythinghandleRequestβ what aspect of requests?
β Clear, focused names:
validateOrder, thensaveOrderβ separate concernsUserAuthenticator,UserRepositoryβ specific rolesparseRequest,authorizeRequestβ distinct operations
Domain language over programmer jargon
Use terms from the problem domain, not computer science abstractions.
β Generic programmer terms:
UserFactoryβ pattern name, not domain conceptDataAccessLayerβ technical architecture termRequestProcessorβ says nothing about business logic
β Domain-specific language:
RegistrationServiceβ what business process?OrderRepositoryβ what domain objects?PaymentValidatorβ what business rules?
Common Pitfalls
β Avoid:
- Suffixes that hide poor design: Handler, Manager, Processor, Helper, Utility
- Generic containers: data, info, result, response, object
- Technical jargon when domain terms exist
- Names longer than 4 words (signals confused design)
- Abbreviations that obscure meaning (usrMgr, procReq)
β Do:
- Use nouns for objects, verbs for functions
- Make illegal states unrepresentable in names
- Let the type system handle types (no
userArray, justusers) - When stuck naming, question the design first
- Rename aggressively when understanding improves
Examples
β Good: Names reveal intent
TYPE PositiveAmount = number // constrained type
TYPE ValidatedEmail = string // passed validation
FUNCTION calculateRefundAmount(order, returnedItems):
// Name reveals purpose, not implementation
FUNCTION authenticateUser(credentials):
// Returns authenticated user or error
FUNCTION eligibleForDiscount(customer, order):
// Boolean reveals business rule
CONST MINIMUM_ORDER_VALUE = 50
CONST MAXIMUM_RETRY_ATTEMPTS = 3
// Names encode constraints and intent
// No comments needed
// Clear from reading alone
Every name tells a story. Intent is obvious. Constraints explicit.
β Bad: Names hide intent
FUNCTION process(data):
// What is being processed? How?
FUNCTION handleUser(u):
// Handle how? Create? Update? Delete?
FUNCTION doStuff(x, y):
// Completely opaque
CONST VALUE = 50 // What does this limit?
CONST LIMIT = 3 // Limit of what?
VAR temp = getUserData()
VAR result = processData(temp)
VAR info = result.data
// Generic names everywhere
// Must read implementation to understand
// Intent buried in code
Names reveal nothing. Must read implementation. Maintenance nightmare.
Naming Patterns
Booleans and Predicates
- Prefix with
is,has,can,should:isValid,hasPermission - Use positive names:
isEnablednotisNotDisabled - Make the condition explicit:
isOverBudgetnotcheckBudget
Collections
- Use plural nouns:
users,orders,transactions - Name reveals filtering:
activeUsers,paidInvoices,recentPosts - Name reveals relationship:
usersByEmail,ordersByDate
Functions
- Verbs for actions:
calculate,validate,transform - Reveal what changes:
createUser,deleteOrder,updateInventory - Query vs Command:
getUser(query) vsfetchUser(command with effects)
Constants
- ALL_CAPS for true constants:
MAX_RETRIES,DEFAULT_TIMEOUT - Reveal the constraint:
MINIMUM_PASSWORD_LENGTHnotPASSWORD_LIMIT
AI Review Checklist
When reviewing code, verify naming decisions:
- [ ] Can you understand the code's purpose without comments?
- [ ] Do names reveal business domain, not implementation?
- [ ] Are generic terms (data, info, manager, handler) replaced with specific names?
- [ ] Do boolean names clearly state the condition being checked?
- [ ] Are constraints and invariants visible in type/variable names?
- [ ] Can you remove "And" from any function names by splitting?
- [ ] Do abbreviations obscure meaning? Can they be spelled out?
If name requires a comment to explain β REJECT and ask for clearer name
If name uses "Manager", "Handler", "Helper" β WARN and suggest specific role
If function name includes "And" β SUGGEST splitting into multiple functions
Related Patterns
- Explicit State Invariants: Names should reveal state requirements
- Single Responsibility: If you can't name it simply, it does too much
- Type-Driven Design: Types and names work together to encode constraints
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.