I have the following question.
Assume we have third party software that send us transaction (atm cards) information in following style:
atm card 4**5048 debited 42$. 231$ Left.
So, I have debited sum, sum left and card no in each transaction.
So I create class
class Transaction {
private String mCardNo;
private Double mAmount; // Actually. I dont store money as double, but let it be:)
private Double mSumLeft;
}
One day second software appears and starts to send the info:
atm card 4**5048 debited 42$: purchase at Apple Store. 231$ Left.
And I think that its awesome to have info about place, where user made a purchase.
There are two options: extend Transaction class or add a new attribute “place”.
One day new software is added and now I have to support 3 types of message!
atm card Visa Classic 4**5048 debited 42$: purchase at Apple Store. 231$ Left.
Oh, God! and Im pretty sure that it will be more than 100 types of messages containing unique numbers of attributes (because I have about 50 now!)
So what is the best way to store additional attributes?
If there’s so much variability in the number of attributes, maybe you should store them in a single class (to avoid an explosion of subclasses) as values in a series of
Mapattributes and identify them with aStringkey (say,Map<String, Double>,Map<String, Integer>, etc.)