The Adapter Nobody Needs

PriceEngine.total(order) returns an int number of cents. A new finance export needs Decimal dollars, rounded to two places exactly once.

Facts on the table: PriceEngine is in your repo, owned by your team. It has two callers, both in the same repo. Line coverage on it is 94 percent. It is not published to any package registry and no other service imports it. A colleague proposes writing DecimalPriceAdapter so PriceEngine is not touched.

What is the right call?

A

Extract a PriceEngine interface with IntPriceEngine and DecimalPriceEngine implementations so the unit becomes configurable.

B

Change PriceEngine.total to return Decimal dollars, update the two call sites and their tests, and delete nothing else.

C

Write the adapter. The Open/Closed Principle says existing classes should be extended rather than modified, and the adapter keeps the change additive.

D

Add a second method PriceEngine.totalDecimal(order) beside the existing one so neither caller has to change.