J90 X


Published on

The finer points of having really clean code.

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Line length … really follow the rule of 6. If you have more than 6 things for a programmer to remember, their brain is going to blow up.
  • As Java developers, we all have an innate, burning desire to write the cleanest code possible. If given the opportunity, each and every one else would write code so clean you could read it to your kids as a bed time story. That’s just the thing, “If given the opportunity”. Developers don’t write bad code; bad situations write bad code. At some point in our coding careers we’ve all had the sneaky feeling that we’ve compromised our clean code instinct. Perhaps the code you were working on was poor condition. Perhaps there was a deadline and it just needed to get done. Whatever the case, at some point we’ve probably set our convictions aside because there looked like there was just no hope. Men like Martin Fowler, Robert “Uncle Bob” Martin, Ward Cunningham, and Kent Beck have been in those situations and they have found the answers. They have solved the problems that cursed programmers as recently as 8 – 10 years ago. They have given us a tremendous gift. And with that let’s look at some code.. That feeling is really what started me on a quest to discover what it means to write clean code. It was a desire to know and have the confidence that my code was the absolute cleanest it could possibly be.
  • Let’s talk about how not to get there…“Uncle Bob” talks about the grand redesign in the sky.Someday, your code base is going to get the golden seal of being rewritten. What a glorious that will be! We shall pool the most talented programmers “Tiger Team” into one project and dream of the ultimate design.ANNNNNNNNNNNNNNNNNNNThis point is talked about in Refactoring as well. Creating clean code is like eating an elephant, one bit at a time. Taking the big rewrite jump could land you with some of the same predicaments as beforeThe most important tool in creating clean code is having worthwhile unit tests backing your base.
  • The best tool get your code cleanIt’s so much fun thinking of the perfect design for code and making UML documents etc.Test driven development drives the perfect design out of your codebase. It makes writing dirty code painful!The cleanliness of your tests is has a direct correlation with your design. One assert per test!!
  • J90 X

    1. 1. J90X<br />Java Flab into Fab<br />
    2. 2. What -> Clean Code?<br />
    3. 3. Source: Clean Codepage 77<br />
    4. 4. “”I could list all of the qualities that I notice in clean code, but there is one overarching quality that leads to all of them. Clean code always looks like it was written by someone who cares.””<br />-Michael Feathers<br />author of “Working Effectively with Legacy Code”<br />
    5. 5. How -> Clean Code<br />
    6. 6. Test Driven Development -> Clean<br />
    7. 7. Clean Code -> …<br />Temporary Variables<br />Method Parameters<br />Zero!<br />One … okay<br />Two … some situations<br />Three … rare<br />Four <br />Clean now. Optimize Later<br />Reads like a newspaper<br />
    8. 8. Really Clean Code -> “AND”<br />
    9. 9. Really Clean Code -> Impl<br />
    10. 10. Really Clean Code ->Hides Generics<br />
    11. 11. Really Clean Code ->Maps<br />
    12. 12. Really Clean Code -><br />Doesn’t Ask, it Tells<br />
    13. 13. Clean Code -> References<br />Example Source Code<br />http://code.google.com/p/flabby-raffle/<br />Martin, Robert C. Clean Code: a Handbook of Agile Software Craftsmanship. Upper Saddle River, NJ: Prentice Hall, 2009. Print.<br />Fields, Jay, Shane Harvie, and Martin Fowler. Refactoring. Upper Saddle River, NJ: Addison-Wesley, 2010. Print.<br />Freeman, Steve, and Nat Pryce. Growing Object-oriented Software, Guided by Tests. Upper Saddle River, NJ: Addison Wesley, 2010. Print.<br />
    14. 14. Mike Menne<br />@<br />Twitter: mpmenne<br />LinkedIn: http://www.linkedin.com/in/mmenne<br />Likes: <br />