Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
50 lines
1.9 KiB
Markdown
50 lines
1.9 KiB
Markdown
# 1. Goal
|
|
The class {{P}}CAKE_PRICER calculates the price of a custom cake order. The
|
|
code is old and hard to maintain. Refactor the class. The behavior must stay
|
|
the same. A shop program calls the class before it shows the price to the
|
|
customer.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}CAKE_PRICER exists in package $TMP. It is active.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The class has one public method, CALCULATE_PRICE, and three public types.
|
|
- The current implementation is one long method. It has deep nesting, magic
|
|
numbers, dead code and an unused variable. The results of the method are
|
|
correct.
|
|
|
|
# 4. Contract
|
|
- Keep the class {{P}}CAKE_PRICER in package $TMP. Keep the name.
|
|
- Keep the public interface. Do not change it:
|
|
- TYPES ty_price TYPE p LENGTH 8 DECIMALS 2.
|
|
- TYPES ty_filling TYPE c LENGTH 1.
|
|
- TYPES ty_decoration TYPE c LENGTH 1.
|
|
- METHOD calculate_price
|
|
IMPORTING iv_size TYPE i
|
|
iv_layers TYPE i
|
|
iv_filling TYPE ty_filling
|
|
iv_decoration TYPE ty_decoration
|
|
iv_express TYPE abap_bool
|
|
RETURNING VALUE(rv_price) TYPE ty_price.
|
|
- Do not add other public methods or public attributes.
|
|
|
|
# 5. Business rules
|
|
- The behavior of the class stays the same.
|
|
- Read the current implementation in {{P}}CAKE_PRICER. Keep every result.
|
|
- Do not change the meaning of an input value or of the returned price.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Refactor the class in place. Do not create a new class.
|
|
- Coding standards: Clean ABAP. Methods below 40 statements. No deep nesting.
|
|
No unused variable. No magic number in the code. No comment that restates
|
|
the code.
|
|
- Out of scope: do not change the public interface of {{P}}CAKE_PRICER.
|
|
|
|
# 7. Acceptance
|
|
- The class {{P}}CAKE_PRICER is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|