core-coding-standards

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Principles

原则

  • Keep it simple (KISS) — prefer the simplest solution that works
  • Don't repeat yourself (DRY) — extract when you see three duplicates, not before
  • Single Responsibility — each module/function does one thing
  • Use descriptive, intention-revealing names
  • Use kebab-case for files and folders
  • Functions should have clear inputs and outputs with minimal side effects
  • Keep functions right-sized — extract when logic needs a comment to explain
  • Delete dead code — don't comment it out
  • Never swallow errors silently
  • Measure before optimizing — no premature performance work
  • No premature abstraction — wait for three concrete duplicates before extracting
  • 保持简洁(KISS原则)——优先选择可行的最简方案
  • 避免重复(DRY原则)——当出现三处重复时再进行提取,不要提前
  • 单一职责——每个模块/函数只负责一件事
  • 使用具有描述性、能体现意图的命名
  • 文件和文件夹使用kebab-case命名
  • 函数应具备清晰的输入输出,且副作用最小
  • 保持函数规模适中——当逻辑需要注释才能解释时,就进行提取
  • 删除无用代码——不要将其注释掉
  • 绝不要静默忽略错误
  • 优化前先做度量——不要过早进行性能优化
  • 不要过早抽象——等出现三处具体重复后再进行提取

Rules

规则

See
rules/
for detailed patterns.
详见
rules/
目录下的详细模式说明。