name
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNaming Conventions
命名规范
Act as a top-tier software engineer who knows how to give clear, descriptive names to functions and variables.
Suggest names for: $ARGUMENTS
Apply these naming rules and give your recommendation with reasoning:
请以顶尖软件工程师的身份,为函数和变量赋予清晰、具有描述性的名称。
为以下内容建议名称:$ARGUMENTS
请遵循以下命名规则并给出你的推荐及理由:
General
通用规则
- Use active voice and clear, consistent naming.
- Functions should be verbs, e.g. increment(), filter().
- Boolean variables should read like yes/no questions, e.g. isActive, hasPermission.
- Prefer standalone verbs over noun.method, e.g. createUser() not User.create().
- Avoid noun-heavy and redundant names.
- Avoid "doSomething" style names.
- Lifecycle methods: prefer beforeX / afterX over willX / didX.
- Use strong negatives over weak ones: isEmpty(thing) not !isDefined(thing).
- Mixins and function decorators: with${Thing}, e.g. withUser, withAuth.
- Follow framework specific naming conventions (React PascalCase components, hooks prefixed with use, etc.).
- 使用主动语态和清晰、一致的命名方式。
- 函数名称应为动词,例如 increment()、filter()。
- 布尔变量的名称应类似是非问句,例如 isActive、hasPermission。
- 优先使用独立动词而非“名词.方法”的形式,例如使用 createUser() 而非 User.create()。
- 避免过度使用名词和冗余名称。
- 避免使用“doSomething”这类模糊的名称。
- 生命周期方法:优先使用 beforeX / afterX 而非 willX / didX。
- 使用明确的否定表达而非模糊的否定:例如使用 isEmpty(thing) 而非 !isDefined(thing)。
- 混入(Mixin)和函数装饰器:使用 with${Thing} 格式,例如 withUser、withAuth。
- 遵循框架特定的命名规范(如React组件使用PascalCase,Hooks以use为前缀等)。
Facade Functions (only for *-model.ts files)
Facade函数(仅适用于*-model.ts文件)
- Pattern:
<action><Entity><OptionalWith...><DataSource><OptionalBy...>() - Allowed actions: save | retrieve | update | delete
- Entity names: singular, PascalCase
- Use "With..." for included relations, "By..." for lookup keys
- DataSource: "ToDatabase" (create), "FromDatabase" (reads), "InDatabase" (updates)
- 模式:
<action><Entity><OptionalWith...><DataSource><OptionalBy...>() - 允许的动作:save | retrieve | update | delete
- 实体名称:单数,采用PascalCase格式
- 使用“With...”表示包含关联关系,“By...”表示查找键
- 数据源:"ToDatabase"(创建)、"FromDatabase"(读取)、"InDatabase"(更新)
Factory Functions (only for *-factories files)
工厂函数(仅适用于*-factories文件)
- Start with createPopulated for base/compound entities.
- Compound names enumerate included relations with With...And...
- 基础/复合实体的工厂函数以createPopulated开头。
- 复合名称使用With...And...枚举包含的关联关系。
Boolean Functions
布尔函数
- Variables in active voice: isActive, hasExpired, isDeactivated
- Standalone functions: prefix with get -> getIsActive(entity), getHasExpired(date)
- 变量使用主动语态:isActive、hasExpired、isDeactivated
- 独立函数:以get为前缀 -> getIsActive(entity)、getHasExpired(date)