data class SpecialTypeContract(
val value: BigDecimal,
val excess: BigDecimal
)
data class CustomerContract(
val name: String,
val value: BigDecimal,
val specialType: SpecialTypeContract?,
val itemContracts: List<ItemContract>
)
data class ItemContract(
val name: String,
val value: BigDecimal,
val excess: BigDecimal
)
Category | options
TypeA | Special
TypeB | item and special
TypeC | item
TypeD | item
In my application, I allow customers to purchase CustomerContract which can have a collection of ItemContract and/or SpecialTypeContract.
I support many categroies A...D and this can grow. For each of the categories I define whether they are available as SpecialTypeContract or as ItemContract.
For each of the above categories, there is a set of excess options to choose from i.e. 300, 800, 1000. The categories can also have rate/interest levels e.g. 0.1, 2.1 etc.
My question is, is there a design pattern I can use to represent this relationship between the categories and the contracts I have Special and Item ?
How should I represent these categories types A...D and provide what options they are available to customers? Should I use a data structure or some class hierarchy given that the list of types could grow later and have properties such as set of excess available and the rate/interest?
Aucun commentaire:
Enregistrer un commentaire