As I said recently, one of my favorite programming books is Agile Software Development by Robert C. Martin AKA Uncle Bob. The Object Mentor blog that he writes along with others is essential reading. Today he posted a subject very dear to my heart: How big should a function be? Now this topic has been covered many times, not least of all by Steve McConnell in Code Complete, but it's amazing that wherever I work the one constant seems to be huge classes and huge functions and lots and lots of duplicated code. What's with it guys? What's stopping you from creating that new class or breaking that huge function into smaller ones? If you're not sure about how to go about splitting large classes and functions into smaller ones you really should read Martin Fowler's Refactoring.
There you go, I've managed to cram references to all three of my favorite programming books into one rant.
OK, mea-maxima-culpa, I know you don't have to browse far through this blog to see some quite large functions, but I'd like to defend myself by saying that's not how I tend to write production code and when one is explaining a technique or a simplest-thing-that-could-possibly-work it makes more sense to present it as a single block of code. Dig dig, is my hole big enough now?
No comments:
Post a Comment
Note: only a member of this blog may post a comment.