How Object-Oriented Are You      Feeling Today?      Software Craftsmanship 2011        26th May, Bletchley Park          ...
Krzysztof Jelski PRAGMATISTS,PL
AgendaINTRO                 WRAP-UP
The Nine Rules1. Use One level of indentation per method2. Dont use the else keyword3. Wrap all primitives and strings4. U...
Bank Accounts Kata   Think of your personal bank account experience   When in doubt, go for the simplest solution
Features   Deposit, Withdrawal   Transfer   Account Statement (date, amount, balance)   Statement printing   Statemen...
You can start with   Bank Accounts Kata sample code    http://bit.ly/jtOP6F   if you need joda­time    http://bit.ly/kSp...
Wrap-upWhich rules:       were simplest to follow?       hardest?       had biggest impact on design?       you think ...
Rule 1: Use One Level of        Indentation per Method   Method ­> does exactly one thing   Reuse   Readability   Impl...
Rule 2: Dont Use the else               Keyword   Simple cases ­> guard clauses, early returns   Complex cases ­> polymo...
Rule 3: Wrap All Primitives and           Strings   Express intent   Type­safe   Place for behaviour
Rule 4: Use Only One Dot per                Line   Place responsibilities properly   The Law of Demeter            your...
Rule 5: Dont Abbreviate   Remove duplication   Place responsibilities properly
Rule 6: Keep All Entities Small   Single Responsibility Principle   Cohesive packages
Rule 7: Dont Use Any Classes    with More Than Two Instance   Class cohesion                   Variables   Find commonal...
Rule 8: Use First-Class                Collections   Home for collection­related behaviour
Rule 9: Dont Use Any      Getters/Setters/Properties   Strong encapsulation boundaries   “Tell, dont ask”
References   Object Calisthenics, Jeff Bay in: The ThoughtWorks Anthology,       Pragmatic Bookshelf 2008.               ...
Upcoming SlideShare
Loading in …5
×

How object oriented are you feeling today?

1,673 views

Published on

Slides from my session at Software Craftsmanship 2011 Conference

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
1,673
On SlideShare
0
From Embeds
0
Number of Embeds
31
Actions
Shares
0
Downloads
18
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

How object oriented are you feeling today?

  1. 1. How Object-Oriented Are You Feeling Today? Software Craftsmanship 2011 26th May, Bletchley Park Krzysztof Jelski
  2. 2. Krzysztof Jelski PRAGMATISTS,PL
  3. 3. AgendaINTRO WRAP-UP
  4. 4. The Nine Rules1. Use One level of indentation per method2. Dont use the else keyword3. Wrap all primitives and strings4. Use only one dot per line5. Dont abbreviate (one­ or two­words names)6. Keep all entities small (50 lines/class, 10 classes/package)7. Dont use any classes with more than two instance variables8. Use first class collections9. Dont use any getters, setters or properties
  5. 5. Bank Accounts Kata Think of your personal bank account experience When in doubt, go for the simplest solution
  6. 6. Features Deposit, Withdrawal Transfer Account Statement (date, amount, balance) Statement printing Statement filters
  7. 7. You can start with Bank Accounts Kata sample code http://bit.ly/jtOP6F if you need joda­time http://bit.ly/kSpwNj
  8. 8. Wrap-upWhich rules:  were simplest to follow?  hardest?  had biggest impact on design?  you think you could use in production?
  9. 9. Rule 1: Use One Level of Indentation per Method Method ­> does exactly one thing Reuse Readability Implementation matches name ­> easier to find bugs
  10. 10. Rule 2: Dont Use the else Keyword Simple cases ­> guard clauses, early returns Complex cases ­> polymorphism (Strategy, Null Object)
  11. 11. Rule 3: Wrap All Primitives and Strings Express intent Type­safe Place for behaviour
  12. 12. Rule 4: Use Only One Dot per Line Place responsibilities properly The Law of Demeter  your toys  toys that you make  toys someone gives you
  13. 13. Rule 5: Dont Abbreviate Remove duplication Place responsibilities properly
  14. 14. Rule 6: Keep All Entities Small Single Responsibility Principle Cohesive packages
  15. 15. Rule 7: Dont Use Any Classes with More Than Two Instance Class cohesion Variables Find commonality of instance variables Object Model decomposition
  16. 16. Rule 8: Use First-Class Collections Home for collection­related behaviour
  17. 17. Rule 9: Dont Use Any Getters/Setters/Properties Strong encapsulation boundaries “Tell, dont ask”
  18. 18. References Object Calisthenics, Jeff Bay in: The ThoughtWorks Anthology,  Pragmatic Bookshelf 2008. Pics http://www.flickr.com/photos/jiheffe/3462940215/ http://www.flickr.com/photos/singapore2010/4916726882

×