This is my own attempt at the object-calisthenics assignment.
Things that I do not like about it (smells):
- A lot of pass throughs; Especially with printing: Customer delegates to BankAccount delegates to TransactionHistory - I don't think I modelled this correctly
- I'm not entirely sure that transfer() uses good encapsulation
- I'm tired
- The stupid StringBuffer being passed through for all the print() was a half-thought; I was originally going to do matching on the final buffer, but got lazy.
- All of the printing needs to be refactored to be a separate concern.
Things that I should probably do:
- Actual error checking for negative balances
The Bank Account Kata
Coding exercise based on the strict rules contained in ObjectCalisthenics.pdf. Meant to give a deeper understanding of object-oriented principles.
Think of your personal bank account experience. When in doubt, go for the simplest solution.
Requirements
- Deposit and withdrawal
- Transfer
- Account statement (date, amount, balance)
- Statement printing
- Statement filters (just deposits, withdrawal, date)
- Rules
- Use only one level of indentation per method
- Don’t use the else keyword
- Wrap all primitives and strings
- Use only one dot per line
- Don’t abbreviate
- Keep all entities small (<50 lines)
- Don’t use any classes with more than two instance variables
- Use first-class collections
- Don’t use any getters/setters/properties