hm-coding-philosophy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Human Made Coding Philosophy

Human Made 编码理念

Core Principles

核心原则

Slow is Fast

慢即是快

Prioritize reasoning quality and maintainability over quick fixes. Take time to understand the problem fully before implementing solutions.
优先考虑推理质量和可维护性,而非快速修复。在实现解决方案前,花时间充分理解问题。

Simplicity is Elegance

简洁即优雅

The solution that achieves a goal with the least code is nearly always the best option. Avoid over-engineering, unnecessary abstractions, and premature optimization.
用最少代码实现目标的解决方案几乎总是最佳选择。避免过度工程化、不必要的抽象和过早优化。

Code Quality Hierarchy

代码质量层级

When writing or reviewing code, prioritize in this order:
  1. Correct - Handles edge cases, no bugs
  2. Secure - No vulnerabilities (OWASP top 10, injection, XSS, etc.)
  3. Readable - Clear intent, self-documenting where possible
  4. Elegant - Clean abstractions, DRY without over-abstraction
  5. Altruistic - Considers future maintainers, well-documented
If code has issues at a lower level (correctness, security), address those before concerning yourself with style or elegance.
在编写或评审代码时,按以下优先级排序:
  1. 正确 - 处理边缘情况,无bug
  2. 安全 - 无漏洞(OWASP top 10、注入、XSS等)
  3. 可读 - 意图清晰,尽可能自文档化
  4. 优雅 - 简洁的抽象,遵循DRY原则但不过度抽象
  5. 利他 - 考虑未来维护者,文档完善
如果代码在较低层级(正确性、安全性)存在问题,应先解决这些问题,再考虑风格或优雅性。

Avoid Over-Engineering

避免过度工程化

  • Don't add features beyond what was requested
  • Don't refactor surrounding code unless asked
  • Don't add error handling for scenarios that can't happen
  • Don't create abstractions for one-time operations
  • Don't design for hypothetical future requirements
  • Three similar lines of code is better than a premature abstraction
  • 不要添加超出需求的功能
  • 除非有要求,否则不要重构周边代码
  • 不要为不可能发生的场景添加错误处理
  • 不要为一次性操作创建抽象
  • 不要为假设性的未来需求做设计
  • 三行相似的代码好过过早的抽象

Documentation Standards

文档标准

  • Use imperative mood: "Display the date" not "Displays the date"
  • Add docblocks where linters require them
  • Strive for self-documenting code
  • Add inline comments only where logic isn't self-evident
  • Don't create documentation files unless explicitly requested
  • 使用祈使语气:例如使用「Display the date」而非「Displays the date」
  • 在代码检查工具要求的地方添加docblocks
  • 力求代码自文档化
  • 仅在逻辑不明显的地方添加行内注释
  • 除非明确要求,否则不要创建文档文件