Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
56 lines
2.5 KiB
Markdown
56 lines
2.5 KiB
Markdown
# 1. Goal
|
|
Refactor the class {{P}}LOCKSMITH_PRICER in package $TMP. A locksmith shop uses
|
|
the class to price its jobs. The class works, but the code is hard to read and
|
|
hard to maintain. Make the code clean. The behavior stays the same.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_LOCKSMITH_PRICER exists in package $TMP. It is active.
|
|
- The interface has the types TY_JOB_TYPE (CHAR 1), TY_KEY_TYPE (CHAR 1),
|
|
TY_CALLOUT (CHAR 1) and TY_AMOUNT (packed number, length 9, 2 decimals).
|
|
- The interface has one method CALCULATE_PRICE. The importing parameters are
|
|
IV_JOB_TYPE, IV_QUANTITY, IV_KEY_TYPE and IV_CALLOUT. The returning parameter
|
|
is RV_PRICE.
|
|
- The class {{P}}LOCKSMITH_PRICER exists in package $TMP. It is active, public
|
|
and final. It implements {{P}}IF_LOCKSMITH_PRICER.
|
|
- The class has no other public members.
|
|
- A job is a key duplication (job type K), a lockout (job type L) or a rekey of
|
|
a cylinder (job type R).
|
|
|
|
# 4. Contract
|
|
- Keep the class {{P}}LOCKSMITH_PRICER in package $TMP.
|
|
- The class stays public and final.
|
|
- The class stays an implementation of {{P}}IF_LOCKSMITH_PRICER.
|
|
- Do not change the interface {{P}}IF_LOCKSMITH_PRICER.
|
|
- Do not add other public methods, types, constants or attributes to the class.
|
|
- The result of the method CALCULATE_PRICE stays the same for every input.
|
|
|
|
# 5. Business rules
|
|
- The current implementation of the class is the specification of the pricing
|
|
rules. Read the code.
|
|
- The refactored class must return exactly the same price as the current class
|
|
for every possible combination of the input parameters.
|
|
- Do not change, add or remove a pricing rule.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
|
- Coding standards: Clean ABAP.
|
|
- Every method has fewer than 40 statements.
|
|
- The nesting depth of a method is at most three.
|
|
- Replace magic numbers with constants that have a meaning.
|
|
- One method does one task. Give each method a name that says what it does.
|
|
- No global variables.
|
|
- No comment that restates the code.
|
|
- Out of scope: do not change {{P}}IF_LOCKSMITH_PRICER. Do not rename the class
|
|
or the method. Do not change the parameter names, the parameter types or the
|
|
parameter order.
|
|
|
|
# 7. Acceptance
|
|
- The class {{P}}LOCKSMITH_PRICER is active and has no syntax error.
|
|
- The class still implements {{P}}IF_LOCKSMITH_PRICER.
|
|
- The hidden tests pass.
|
|
- The class returns the same prices as before.
|
|
- Write your own ABAP Unit tests in the local test classes of the class.
|