Files

1.7 KiB

1. Goal

Refactor the class {{P}}KENNEL_PRICER. The class calculates the boarding fee of a pet at a kennel. The class works correctly. The code is difficult to read and to maintain. Refactor the class. The behavior stays the same.

2. Open questions

None.

3. Context

  • The class {{P}}KENNEL_PRICER exists in package $TMP. It is active.
  • A booking program calls the class before the kennel confirms a booking.
  • The booking program must get the same fee after your change.
  • The class has one public method. The method calculates the fee.

4. Contract

  • Change the class {{P}}KENNEL_PRICER in package $TMP. Keep the name of the class.
  • Keep the public interface of the class. These public components stay:
    • The type TY_PET_TYPE. It is CHAR 4.
    • The type TY_AMOUNT. It is P, length 8, 2 decimals.
    • The method CALCULATE_FEE with this signature: IMPORTING iv_pet_type TYPE ty_pet_type iv_nights TYPE i iv_high_season TYPE abap_bool iv_grooming TYPE abap_bool RETURNING VALUE(rv_fee) TYPE ty_amount.
  • Do not add other public methods or public attributes.

5. Business rules

The behavior of the class must not change. Read the existing implementation in the seed object. Every result value stays the same. This includes the results for edge cases and for unusual input values.

6. Constraints

  • Release target: 8.16.
  • Coding standards: Clean ABAP. Method length below 40 statements. No magic numbers. No deep nesting. No comment that restates the code.
  • Out of scope: none.

7. Acceptance

  • The class is active and has no syntax error.
  • The hidden tests pass.
  • Write your own ABAP Unit tests for the class.