I was doing some “house cleaning” today of my, by now, massive “Blogs” favorites folder and saw a few blogs i simply couldn’t put a “face” to.
Being curious by nature i ventured over to satisfy myself and see whatever it was that made me bookmark this blog.
The target of my curiosity was Scott Reynold’s blog and after having a brief look i saw why it’d been bookmarked…
I came across a very interesting post by the man himself – Code Reuse is Not the Villain – which factored some of the things i value very highly in development…code reuse.
i’m not just talking about cutting some code into your toolbar to drag in, or adding a snippet to your snippet library in VS.
No, i’m talking about taking that extra moment to consider not just the use, but also the place in the project where the class is going to live..
Many developers apply MVP or MVC patterns, sometimes even without knowing about it, which means there’s intuition involved (or experience?) when making that decision.
Others adhere strictly to a company wide architecture which is set in concrete and out-of-bounds for the regular developer as the architect is the owner of it.
Scott mentions a few tips which i think should be “advertised” a bit more in general.
- Aim for zero development for reusable code – you don’t want to have to re-write half of your class just to suit it to another project.
- refactoring is NOT necessarily the key to reusable libraries.
And here’s a few from me…
- Consider heavily the “reusability” of your class before you start spending time on attempting to make it reusable.
- Plan your code BEFORE you throw yourself into the first “private partial class”.
As Scott says, a lot of code just isn’t meant to be reusable…
Scott went out on a limb with that one, or so he claims but i seriously think it’s one of the more important points…We all know that buzzwords like OOD and OOA are thrown around the floor constantly, but can you truly say that ALL your code is completely OO? I’d venture as far as to say that less than what you think is actually true to that fact.