52 lines
2.2 KiB
Markdown
52 lines
2.2 KiB
Markdown
# 1. Goal
|
|
The optician shop uses the class {{P}}GLASSES_PRICER to calculate the price of a
|
|
glasses order. A sales program calls the class for each quotation. The class is
|
|
legacy code. It is hard to read and hard to test. Refactor the class. The
|
|
behavior must stay the same.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}GLASSES_PRICER exists in package $TMP. It is active.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The public interface of the class is:
|
|
- the type TY_AMOUNT (packed number, length 9, 2 decimals),
|
|
- the type TY_LENS (character, length 1),
|
|
- the type TY_COAT (character, length 1),
|
|
- the method PRICE with the importing parameters IV_FRAME (TY_AMOUNT),
|
|
IV_LENS (TY_LENS), IV_COAT (TY_COAT), IV_QTY (TYPE i) and the returning
|
|
parameter RV_PRICE (TY_AMOUNT).
|
|
- The program {{P}}OPTIC_QUOTE_RPT calls the class.
|
|
- The legacy implementation is the specification of the behavior.
|
|
|
|
# 4. Contract
|
|
- Refactor the class {{P}}GLASSES_PRICER in package $TMP. The name stays the same.
|
|
- The class stays public and final and keeps its public constructor without
|
|
parameters.
|
|
- Keep the public types TY_AMOUNT, TY_LENS and TY_COAT.
|
|
- Keep the method PRICE with the same parameter names, the same parameter types
|
|
and the same sequence.
|
|
- Do not add public methods or public attributes.
|
|
- Do not create other objects.
|
|
|
|
# 5. Business rules
|
|
- The behavior of the class must not change. For every input, PRICE must return
|
|
the same value as the legacy method.
|
|
- The legacy code holds all rules, including its limits and its default values.
|
|
- Do not add a rule. Do not remove a rule. Do not correct a rule.
|
|
- PRICE returns a price in the currency of the order.
|
|
|
|
# 6. Constraints
|
|
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
|
- Coding standards: Clean ABAP. One method does one thing. Method length below
|
|
40 statements. No deep nesting. No magic numbers: use constants. No duplicated
|
|
code. No dead code. No global variables. No comment that restates the code.
|
|
- Out of scope: do not change the program {{P}}OPTIC_QUOTE_RPT. Do not change
|
|
the public interface of the class.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|