I'm mutants , bank and katana

The student was assigned to a banking company for designing their API. The student was excited as well as slightly exasperated. Master smiled seeing the student. Banking companies needed a fluid design, flexible and extensible beyond all points. It was necessary as the bank was planning to establish itself as banking solution for people in greece.

The student without wasting his time started implementing an account class and money class. Master watched him with nostalgic eyes. Account object was created in such a way that each and every user was given one account. Account object was mutable. The underlying construct of money was immutable. If you wanted to add money to account then money was added with another value. Money is muted to reflect this change. The code was ready for production. The student was ecstatic. The master saw the code. He entered the terminal and deleted whole code permanently. The student was angry and was ready to unleash his katana.

The master smiled and took him to a coffee shop. They ordered two coffees and the bill came out to be 16 rupees. The master gave the student a 10 rupees note and other 6 rupees in coins. The student took the money and attempted to give it to the shopkeeper. The master used the back of his katana to make the student drop all of his money. The student tried picking it up from the ground. Again, the master made him drop all the money. The student was exhausted and dumped the idea altogether. The master smiled and told the student that he could take it when all entities were of same. There should be no coins at all. You add 6 to 10 rupees note, there should be a note which said 16 rupees. If that was possible he could take the money.

The student was enlightened. He went back and reimplemented the account and money with mutable account class and immutable money class.

Written on July 15, 2015