70 likes | 191 Views
Crafting Object-Oriented Code. Sandro Mancuso @sandromancuso. http://www.londonswcraft.com @londonswcraft. London Software Craftsmanship Community (LSCC). http://www.londonswcraft.com @londonswcraft. Sandro Mancuso @sandromancuso. David Green @activelylazy. Bank Account Kata.
E N D
Crafting Object-Oriented Code Sandro Mancuso @sandromancuso http://www.londonswcraft.com @londonswcraft
London Software Craftsmanship Community (LSCC) http://www.londonswcraft.com @londonswcraft Sandro Mancuso @sandromancuso David Green @activelylazy
Bank Account Kata Note: Stick to the features and take the simplest approach. We are not trying to create a real bank system here. Features Deposit, Withdrawal Transfer (optional) Account Statement (date, amount, balance) Statement printing Statement filters
The Nine Rules1. Use only one level of indentation per method. 2. Don’t use the else keyword. 3. Wrap all primitives and strings. 4. Use only one dot per line. 5. Don’t abbreviate. 6. Keep all entities small (max 50 lines). 7. Maximum two attributes per class. 8. Use first-class collections. 9. Don’t use any getters/setters/properties. Object Calisthenics, Jeff Bay in: The ThoughtWorks Anthology, Pragmatic Bookshelf 2008
The Nine Rules1. Use only one level of indentation per method. 2. Don’t use the else keyword. 3. Wrap all primitives and strings. 4. Use only one dot per line. 5. Don’t abbreviate. 6. Keep all entities small (max 50 lines). 7. Maximum two attributes per class. 8. Use first-class collections. 9. Don’t use any getters/setters/properties.RequirementsDeposit & WithdrawalTransfer (optional)Account Statement (date, amount, balance)Statement printingStatement filters
Discussion Which rules... • were the most difficult to follow? • impacted your design? • will you try to follow in the future? • will you not try to follow in the future? Design • What's the name of the class containing the value? Is it immutable? • How did you test deposits and withdrawal? • Which classes did you end up with? • How did you implement the statement? • How far did you get?
Thank you London Software Craftsmanship Community (LSCC) http://www.londonswcraft.com @sandromancuso References - Object Calisthenics, Jeff Bay in: The ThoughtWorks Anthology, Pragmatic Bookshelf 2008 - How Object-Oriented Are You Feeling Today? - Krzysztof Jelski