Why Clear English Naming Matters in Code and How to Do It Right
The article explains why English is essential for global codebases, outlines naming conventions for classes and methods, shows common pitfalls with inaccurate translations, and proposes a collaborative glossary to improve readability and maintainability of software projects.
Programming languages are written in English, so mastering English naming is crucial for writing code that can be understood worldwide.
Basic Naming Rules
Class names should be nouns that represent an object, while method names should be verbs or verb‑object phrases that describe an action.
For a method that marks a translation as completed, use completeTranslation instead of a vague completed or translate .
If the intention is to re‑translate, the method should be named retranslate , not retranslation .
Choosing the Right English Terms
When naming status enums, AuditStatus may seem appropriate, but audit actually means “audit” (financial review) while review conveys a broader verification process. Therefore ReviewStatus is often a better fit.
Many developers rely on Google Translate, leading to inaccurate terms like using audit for code review. Understanding the subtle differences between similar English words helps avoid such mistakes.
Collaborative Glossary Solution
Form a cross‑functional team (product, development, testing) to create a shared glossary of business terms in both Chinese and English. Use this glossary as a reference when naming variables, functions, and classes, aligning with Domain‑Driven Design (DDD) principles.
Dealing with Typos
Spelling errors in identifiers (e.g., sortFiled instead of sortField) are common. Modern IDEs like IntelliJ IDEA can highlight these typos, allowing developers to correct them quickly.
Practical Tips
Prefer clear, descriptive English names over literal translations.
Keep method names in active voice.
Review and refine names with the team to ensure consistency.
By following these guidelines, code becomes more maintainable, easier to read for international teams, and aligns with best practices in software engineering.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
JavaEdge
First‑line development experience at multiple leading tech firms; now a software architect at a Shanghai state‑owned enterprise and founder of Programming Yanxuan. Nearly 300k followers online; expertise in distributed system design, AIGC application development, and quantitative finance investing.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
