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?
Transactionare in fact attributes, they're properties. Other than that, you might consider a more loosely typed approach, where types can be extended without the class being extended per se by means of a 'property bag'-like implementation.Stringdata typeDoubleindicates that it might not be C# - unless they're into avoiding language-specific aliases for 'native' types. Still a possibility, not that it matters that much.