際際滷

際際滷Share a Scribd company logo
How Object-Oriented Are You
      Feeling Today?



      Software Craftsmanship 2011
        26th May, Bletchley Park

            Krzysztof Jelski
Krzysztof Jelski

 PRAGMATISTS,PL
Agenda
INTRO




                 WRAP-UP
The Nine Rules
1. UseOnelevelofindentationpermethod
2. Don'tusetheelsekeyword
3. Wrapallprimitivesandstrings
4. Useonlyonedotperline
5. Don'tabbreviate(one足ortwo足wordsnames)
6. Keepallentitiessmall(50lines/class,10classes/package)
7. Don'tuseanyclasseswithmorethantwoinstancevariables
8. Usefirstclasscollections
9. Don'tuseanygetters,settersorproperties
Bank Accounts Kata
   Thinkofyourpersonalbankaccountexperience
   Whenindoubt,goforthesimplestsolution
Features
   Deposit,Withdrawal
   Transfer
   AccountStatement(date,amount,balance)
   Statementprinting
   Statementfilters
You can start with
   BankAccountsKatasamplecode

    http://bit.ly/jtOP6F
   ifyouneedjoda足time

    http://bit.ly/kSpwNj
Wrap-up
Whichrules:
       weresimplesttofollow?
       hardest?
       hadbiggestimpactondesign?
       youthinkyoucoulduseinproduction?
Rule 1: Use One Level of
        Indentation per Method
   Method足>doesexactlyonething
   Reuse
   Readability
   Implementationmatchesname足>easiertofindbugs
Rule 2: Don't Use the else
               Keyword
   Simplecases足>guardclauses,earlyreturns
   Complexcases足>polymorphism(Strategy,NullObject)
Rule 3: Wrap All Primitives and
           Strings
   Expressintent
   Type足safe
   Placeforbehaviour
Rule 4: Use Only One Dot per
                Line
   Placeresponsibilitiesproperly
   TheLawofDemeter
            yourtoys
            toysthatyoumake
            toyssomeonegivesyou
Rule 5: Don't Abbreviate
   Removeduplication
   Placeresponsibilitiesproperly
Rule 6: Keep All Entities Small
   SingleResponsibilityPrinciple
   Cohesivepackages
Rule 7: Don't Use Any Classes
    with More Than Two Instance
   Classcohesion
                   Variables
   Findcommonalityofinstancevariables
   ObjectModeldecomposition
Rule 8: Use First-Class
                Collections
   Homeforcollection足relatedbehaviour
Rule 9: Don't Use Any
      Getters/Setters/Properties
   Strongencapsulationboundaries
   Tell,don'task
References
   ObjectCalisthenics,JeffBayin:TheThoughtWorksAnthology,
      PragmaticBookshelf2008.


                              Pics

   http://www.flickr.com/photos/jiheffe/3462940215/
   http://www.flickr.com/photos/singapore2010/4916726882

More Related Content

How object oriented are you feeling today?

  • 1. How Object-Oriented Are You Feeling Today? Software Craftsmanship 2011 26th May, Bletchley Park Krzysztof Jelski
  • 3. Agenda INTRO WRAP-UP
  • 4. The Nine Rules 1. UseOnelevelofindentationpermethod 2. Don'tusetheelsekeyword 3. Wrapallprimitivesandstrings 4. Useonlyonedotperline 5. Don'tabbreviate(one足ortwo足wordsnames) 6. Keepallentitiessmall(50lines/class,10classes/package) 7. Don'tuseanyclasseswithmorethantwoinstancevariables 8. Usefirstclasscollections 9. Don'tuseanygetters,settersorproperties
  • 5. Bank Accounts Kata Thinkofyourpersonalbankaccountexperience Whenindoubt,goforthesimplestsolution
  • 6. Features Deposit,Withdrawal Transfer AccountStatement(date,amount,balance) Statementprinting Statementfilters
  • 7. You can start with BankAccountsKatasamplecode http://bit.ly/jtOP6F ifyouneedjoda足time http://bit.ly/kSpwNj
  • 8. Wrap-up Whichrules: weresimplesttofollow? hardest? hadbiggestimpactondesign? youthinkyoucoulduseinproduction?
  • 9. Rule 1: Use One Level of Indentation per Method Method足>doesexactlyonething Reuse Readability Implementationmatchesname足>easiertofindbugs
  • 10. Rule 2: Don't Use the else Keyword Simplecases足>guardclauses,earlyreturns Complexcases足>polymorphism(Strategy,NullObject)
  • 11. Rule 3: Wrap All Primitives and Strings Expressintent Type足safe Placeforbehaviour
  • 12. Rule 4: Use Only One Dot per Line Placeresponsibilitiesproperly TheLawofDemeter yourtoys toysthatyoumake toyssomeonegivesyou
  • 13. Rule 5: Don't Abbreviate Removeduplication Placeresponsibilitiesproperly
  • 14. Rule 6: Keep All Entities Small SingleResponsibilityPrinciple Cohesivepackages
  • 15. Rule 7: Don't Use Any Classes with More Than Two Instance Classcohesion Variables Findcommonalityofinstancevariables ObjectModeldecomposition
  • 16. Rule 8: Use First-Class Collections Homeforcollection足relatedbehaviour
  • 17. Rule 9: Don't Use Any Getters/Setters/Properties Strongencapsulationboundaries Tell,don'task
  • 18. References ObjectCalisthenics,JeffBayin:TheThoughtWorksAnthology, PragmaticBookshelf2008. Pics http://www.flickr.com/photos/jiheffe/3462940215/ http://www.flickr.com/photos/singapore2010/4916726882