返回 Skill 列表
extension
分类: 开发与工程无需 API Key

refactor-rename-for-clarity

[代码质量] 进行系统性的重命名以提高代码清晰度:变量、函数、类、文件。当名称不清楚、具有误导性或与其用途不一致时使用。

person作者: jakexiaohubgithub

Refactor: Rename for Clarity

Improve code readability through better naming.

Naming Principles

1. Names Should Reveal Intent

// BAD: let d: Int
// GOOD: let elapsedDays: Int

2. Names Should Be Searchable

// BAD: if status == 1 { }
// GOOD: if status == .active { }

3. Names Should Match Abstraction Level

// BAD: func getFromNetworkAndParseJSON()
// GOOD: func fetchUserProfile()

Common Patterns

| Bad Name | Better Name | Why | |----------|-------------|-----| | data | userResponse | Specific type | | temp | previousValue | Purpose clear | | flag | isEnabled | Boolean pattern | | doIt() | submitForm() | Action + target |