in the project I am currently working on we had three different types of prices depending on the age of the user (adult, child, etc...). So we had on the DB a table looking like this:
PRICES type Amount A 20 B 15 C .. D ..
At first we only had 4 different types of prices, so in the code, we had something like this:
Map<String, BigDecimal> prices = new HashMap<String, BigDecimal>();
Where the keys were the price type.
Recently, they added a new business rule that adds 3 subtypes to every price type, so now we have something like this:
PRICES type subtype Amount A 1 20 A 2 15 A 3 .. B 1 .. B 2 .. ... .. ..
Which of the following two options do you think is better and why?
Map<String, Map<String, BigDecimal>> prices;
where the keys are the price type and subtype:
The same map than originally:
Map<String, BigDecimal> prices;
And concatenate the keys to index the different prices: