49 lines
2.2 KiB
Markdown
49 lines
2.2 KiB
Markdown
# 1. Goal
|
|
A picture framing shop prices a frame for a customer. The shop measures the
|
|
picture in centimetres and selects a moulding and a glass type. A checkout
|
|
program calls one method for each frame order and needs the total price.
|
|
|
|
The class {{P}}FRAME_PRICER in package $TMP already does this. The code is hard
|
|
to read and hard to maintain. Refactor the class. The behavior stays the same.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}FRAME_PRICER exists in package $TMP. It is active.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- The class has the public types TY_MOULDING (CHAR 1), TY_GLASS (CHAR 1) and
|
|
TY_AMOUNT (packed number with 2 decimal places).
|
|
- The class has one public method CALCULATE_PRICE with the importing parameters
|
|
IV_WIDTH_CM, IV_HEIGHT_CM, IV_MOULDING, IV_GLASS and IV_QUANTITY and the
|
|
returning parameter RV_PRICE.
|
|
- The current implementation contains the complete calculation. Read it.
|
|
|
|
# 4. Contract
|
|
- Refactor the class {{P}}FRAME_PRICER in package $TMP.
|
|
- Keep the class name, the class properties and the complete public interface.
|
|
- Do not add, remove or rename public methods, public types or parameters.
|
|
- The method CALCULATE_PRICE returns the same value as before for every input.
|
|
|
|
# 5. Business rules
|
|
- The behavior of the class stays the same. Every input combination that the
|
|
current implementation accepts must produce the same result.
|
|
- The rules of the calculation are in the current implementation of the class.
|
|
Read them there.
|
|
- The hidden tests check the behavior with valid and invalid input values.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP. Each method has less than 40 statements. Use
|
|
local variables instead of attributes. Use constants instead of magic
|
|
numbers. Use modern ABAP statements and modern comparison operators. Give
|
|
each method one clear task. Do not change the public interface.
|
|
- Out of scope: do not create other objects. Do not change any other object in
|
|
package $TMP.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- The class has no ATC priority 1 or priority 2 finding.
|
|
- Write your own ABAP Unit tests for the class.
|