Thursday, January 7, 2010

The Fallacy of ReUse

I've read The Fallacy of ReUse and while it presents very good arguments against reusing things. Clearly there is a path to reusable code, otherwise why would we have frameworks or .net? Why would we have so many code snippet web sites and webapps? Microsoft wrote a book on this type of reusable code and I'm in the process of reading it. Design patterns are some of the best examples of reusable code that shines or perhaps has been through it's lifecycle and was retired for a better pattern. I'd hardly call a 3-5 yr life cycle something that wasn't reusable.

I think, like most concepts in programming, there is a time and a place for code reuse, designing for reuse, and refactoring/reworking code for the purpose of reuse.

Most businesses, concepts, inventions and products don't happen magically, they are born of failure after failure. Look at how many times Thomas Edison failed to invent various things.

If your position/team/manager leaves you no time for experimentation on tools, concepts, add-ins, macros, frameworks architectures that might improve your overall work speed or team productivity, then reuse attempts/ideas/experimentation is probably not appropriate. However, I don't imagine there's a team out there that couldn't benefit from allocating time for trying alternate ways of doing things, reviewing each others' ways of doing things, or brainstorming for reusable solutions to common problems.

I also don't imagine it's something everyone can do or excel at. Most people give up on most challenges in life, that's what leaves room to strive for excellence and get there (or enjoy the time spent chasing that elusive goal).

There's code that's valuable merely because it's called in 2 places in a class. Isn't this the heart of refactoring and Don't Repeat Yourself? Code reuse to me is shooting for DRY on a slightly higher level than simple class method refactoring, although I work hard at that as well.

It's to see how far out can this reusable code scale?
Many methods in a class can make use of this code? Nice. Many classes in a project can make use of this class? Cool. Many projects in a solution can make use of this code? Sweet. Some of my reusable code is useful in projects outside of my company? Awesome.

Or perhaps I'm just passing along code I found on the web that I believe to be useful. I enjoy that too. I enjoy being someone that might have a corner or edge-case solution that other developers seek me out for.

I enjoy pretty much anything I can do to lure developers into talking code with me and I think this is a valuable niche. So maybe I'm too biased. Either way I enjoy the pursuit, your mileage may vary.

No comments:

Post a Comment