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.”” -Michael Feathers author of “Working Effectively with Legacy Code”
7. Clean Code -> … Temporary Variables Method Parameters Zero! One … okay Two … some situations Three … rare Four Clean now. Optimize Later Reads like a newspaper
13. Clean Code -> References Example Source Code http://code.google.com/p/flabby-raffle/ Martin, Robert C. Clean Code: a Handbook of Agile Software Craftsmanship. Upper Saddle River, NJ: Prentice Hall, 2009. Print. Fields, Jay, Shane Harvie, and Martin Fowler. Refactoring. Upper Saddle River, NJ: Addison-Wesley, 2010. Print. Freeman, Steve, and Nat Pryce. Growing Object-oriented Software, Guided by Tests. Upper Saddle River, NJ: Addison Wesley, 2010. Print.
14. Mike Menne @ Twitter: mpmenne LinkedIn: http://www.linkedin.com/in/mmenne Likes:
Hinweis der Redaktion
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!!