advpl-refactoring

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ADVPL/TLPP Refactoring

ADVPL/TLPP 重构

This skill defines safe refactoring patterns (RF-001 through RF-006) for improving ADVPL/TLPP code structure without altering behavior: extract function, simplify conditionals with guard clauses, remove dead code, improve naming to Hungarian notation, eliminate duplication, and reduce function parameter count. It also defines the mandatory process -- analyze, prioritize, present a before/after plan, wait for user approval, apply one change at a time, verify -- and hard safety rules (never change business logic, never rename externally-used symbols without a caller check).
Activate this skill when the user wants existing, working code restructured for readability or maintainability: long functions, deep nesting, unclear names, copy-pasted blocks, or functions with excessive parameters. It does not cover fixing bugs or errors (see
advpl-debugging
), generating brand-new functionality (see
advpl-code-generation
), a formal quality/security audit (see
advpl-code-review
), or converting procedural
.prw
to object-oriented
.tlpp
(see
advpl-to-tlpp-migration
, which is a structural paradigm change rather than a behavior-preserving cleanup).
Reference fileRead when
reference.mdAlways -- the only file in this skill; contains all refactoring patterns (RF-001 to RF-006), the refactoring process, and safety rules
本技能定义了6种安全重构模式(RF-001至RF-006),用于在不改变代码行为的前提下优化ADVPL/TLPP代码结构:提取函数、使用卫语句简化条件逻辑、移除死代码、将变量命名优化为Hungarian notation规范、消除重复代码、减少函数参数数量。本技能还规定了强制性流程——分析、优先级排序、展示改造前后方案、等待用户批准、单次应用一项变更、验证——以及严格的安全规则:绝不修改业务逻辑,未经调用方检查绝不重命名外部使用的符号。
当用户希望为提升可读性或可维护性重构现有可正常运行的代码时,激活本技能。适用场景包括:长函数、深层嵌套、命名不清晰、复制粘贴的代码块、参数过多的函数。本技能不涵盖以下场景:bug或错误修复(参见
advpl-debugging
)、全新功能生成(参见
advpl-code-generation
)、正式质量/安全审计(参见
advpl-code-review
)、将过程式
.prw
文件转换为面向对象
.tlpp
文件(参见
advpl-to-tlpp-migration
,该操作属于结构范式变更,而非保留行为的代码清理)。
参考文件读取时机
reference.md始终读取——本技能中的唯一文件,包含所有重构模式(RF-001至RF-006)、重构流程及安全规则