47 lines
1.9 KiB
Markdown
47 lines
1.9 KiB
Markdown
# 1. Goal
|
|
A self-storage company rents storage units to private and business customers.
|
|
The class {{P}}STORAGE_PRICER calculates the price of one storage unit
|
|
booking. The class is legacy code. It works, but it is hard to read and hard
|
|
to change. Refactor the class. The behavior stays exactly the same. The class
|
|
name and the public interface stay the same.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}STORAGE_PRICER exists in package $TMP and is active.
|
|
- A checkout program calls the method CALCULATE_PRICE for each booking.
|
|
- The class is the only object of this task.
|
|
|
|
# 4. Contract
|
|
Keep the class {{P}}STORAGE_PRICER in package $TMP. Keep the class name and
|
|
the public interface. The public interface is:
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- Public type TY_AMOUNT: packed number, length 8, 2 decimals.
|
|
- Public type TY_SQM: integer.
|
|
- Public type TY_MONTHS: integer.
|
|
- Public type TY_BOOKING with the components SIZE_SQM (TYPE TY_SQM), MONTHS
|
|
(TYPE TY_MONTHS), CLIMATE (TYPE ABAP_BOOL) and INSURANCE (TYPE ABAP_BOOL).
|
|
- Public method CALCULATE_PRICE with the importing parameter IS_BOOKING
|
|
(TYPE TY_BOOKING) and the returning parameter RV_PRICE (TYPE TY_AMOUNT).
|
|
Do not add public methods or public components. Do not remove a public method
|
|
or a public component.
|
|
|
|
# 5. Business rules
|
|
The legacy code in {{P}}STORAGE_PRICER contains all business rules. Read the
|
|
legacy code. The behavior must stay exactly the same for every input. Do not
|
|
add a rule and do not remove a rule.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP. Methods below 40 statements. No deep nesting.
|
|
No magic numbers; use constants. No global variables. No comment that
|
|
restates the code.
|
|
- Out of scope: no other object.
|
|
|
|
# 7. Acceptance
|
|
- The class {{P}}STORAGE_PRICER is active and has no syntax error.
|
|
- The public interface is unchanged.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|