Each Tariff is composed by a list of Fees. Tariff contains minimal logic and provides unified interface for calculating Fees. Tariff implements Fascade pattern to operate list of Fee objects.
- Tariff is a class representing the main entity the model is going to compare. Tariff, product, service and subscription are hereby considered the same thing. Tariff aggregates a set of fees. Tariff classes are designed to be reused when same pricing model is required, only with different values.
- Fee is is a class that comprises a Tariff - a Tariff has many Fees. Each Fee implement it's own '
Calculate(...)
. E.g. some fees are based on consumption, while others on fixed periods of time. - Applying a fee is the process of calculation of cost - really done in
IFee.Calculate(...)
. WhenCalculate(...)
is called on Tariff object it callsCalculate(...)
on each Fee and aggregates the result
To add a new Tariff extend the abstract Tariff
class.
Extend and implement from IFee
interface. Use the Fee within a Tariff
class.
Override Calculate(...)
from the base abstract Tariff class.
To add features to the model, like add more unit types or change calculation algorithm, re-implement the ITariff
and IFee
interfaces. Consumption
class is also meant to be extended as needed