code-style

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Style Rules

代码风格规则

  • Keep functions small. Split when a function has multiple jobs or needs sections to be readable.
  • Keep files under 300 lines when practical. Split by responsibility, not by arbitrary layer.
  • Prefer object-oriented code over scattered functions.
  • Put higher-order/public functions near the top of the file; keep low-level utilities at the bottom.
  • Write terse, simple English comments. Explain why something is surprising; do not narrate obvious code.
  • Do not add abstractions until there are repeated concrete uses.
For Frappe-specific work, prefer
frappe-app-dev
.
  • 保持函数精简。当一个函数承担多项职责或需要拆分才能保证可读性时,进行拆分。
  • 尽可能将文件行数控制在300行以内。按职责拆分文件,而非按任意层级。
  • 优先使用面向对象代码,而非零散的函数。
  • 将高阶/公共函数放在文件顶部;将底层工具函数放在文件底部。
  • 撰写简洁明了的英文注释。解释代码中令人费解的部分,无需对显而易见的代码进行赘述。
  • 除非存在重复的具体使用场景,否则不要添加抽象层。
针对Frappe相关工作,优先使用
frappe-app-dev