The Challenge
SMO1 needs cat mode (playful: “73 Pawprintz”, “Zoomies ⚡”) and professional mode (corporate: “73 Activity”, “Active”) labels in the same components. Naive approaches create tech debt:- ❌ Two separate component files (CatScoringChips + ProScoringChips) → duplicate logic, divergence
- ❌ Inline ternaries everywhere → noisy, hard to audit all terminology
- ❌ Config file in backend → adds API surface, complicates deployments
Solution: Terminology Mapping + Single Component
Step 1: Extract Label Pairs into Mapping Objects
Step 2: Create Helper Function
Step 3: Use in Component
Step 4: Test Both Modes
Advanced: Status Badges with Emojis
For mappings where cat mode has emojis but professional doesn’t:At Scale: Terminology Registry
For projects with dozens of terminology pairs, centralize in a TypeScript file:Comparison: Other Approaches
| Approach | Code Duplication | Maintenance | Testing | Performance |
|---|---|---|---|---|
| Separate components | High ❌ | Hard ❌ | Complex ❌ | Same |
| Inline ternaries | None ✅ | Hard ❌ | Simple ✅ | Same |
| Terminology mapping | None ✅ | Easy ✅ | Simple ✅ | Same ✅ |
| i18n library | None ✅ | Easy ✅ | Simple ✅ | Slight overhead |
| Backend config | None ✅ | Complex ❌ | Flaky ❌ | Network latency ❌ |
Key Wins
✅ Auditable: All terminology pairs in one place (or one file per feature) ✅ Testable: Add tests incrementally as new terminology is added ✅ No Duplication: Component logic shared between modes ✅ Scalable: Extend terminology object without touching component code ✅ Localizable: If you ever need i18n, translation keys already structuredGotchas
❌ Forgetting a pair: If you add a cat label but forget the pro label, runtime errors reveal it quickly. Use TypeScriptas const for stricter types.
❌ Terminology drift: Terminology file becomes the source of truth. Keep it near components it serves (not buried in utils).
❌ Emoji placement: Emojis should be in the string (not separate DOM), so they stay synchronized with labels during mode changes.