Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
2.3 KiB
2.3 KiB
1. Goal
Refactor the legacy class {{P}}DIVE_CHECK. The class checks if a diver may join a guided dive. A booking program calls the check before it confirms the dive. The behavior of the class stays the same. Improve the structure and the readability of the code.
2. Open questions
None.
3. Context
- The class {{P}}DIVE_CHECK exists in package $TMP. It is active.
- A booking program uses the class. The public interface of the class is fixed.
- The class contains legacy code: one long method, deep nesting, hard-coded numbers, and duplicated statements. Users report no defect. The task is a refactoring, not a repair.
- Read the current source of the class before you change it.
4. Contract
The class {{P}}DIVE_CHECK stays in package $TMP. The class stays public and final. Do not change the public interface.
- Public type TY_REASON: type c, length 10.
- Public type TY_CERT_LEVEL: type c, length 1.
- Public constant structure C_REASON with the components OK, AGE, CERT, DEPTH, DIVES, and RECENT. The component type is TY_REASON. Do not change the values.
- Public instance method CHECK_DIVER with this signature: IMPORTING iv_cert_level TYPE ty_cert_level iv_depth TYPE i iv_dives TYPE i iv_last_dive TYPE d iv_dive_date TYPE d iv_age TYPE i RETURNING VALUE(rv_reason) TYPE ty_reason.
- Do not add other public components. Do not remove a public component.
5. Business rules
- The class keeps its current behavior. Read the legacy code and keep every rule, the sequence of the rules, and every limit.
- Do not add a rule. Do not remove a rule. Do not change a limit. Do not change the sequence of the rules.
- The method returns the reason of the first rule that fails. If no rule fails, the method returns OK.
6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Methods below 40 statements. No global variables. No comment that restates the code. No ATC priority 1 or priority 2 finding.
- Out of scope: do not change the public interface. Do not create other objects. Do not change the behavior.
7. Acceptance
- The class {{P}}DIVE_CHECK is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests as local test classes of the class.