Reinventing the Wheel vs Making Your Own [08/18/2007 15:29:49]
I've been guilty of reinventing the wheel when it comes to web apps. But if I'm going to confess my sin here, I think it's important to clarify exactly what I'm confessing.
I used to think that reinventing the wheel meant writing your own solution when somebody else has already written theirs. I certainly do this a lot, but I don't necessarily consider it a bad thing: I can look at another person's code, understand exactly what they're doing, and prefer to put those ideas into my own code. That's just part of understanding what you're doing, and it's a good thing.
I'm glad that both jQuery and prototype (and others) exist. That's healthy competition, and it's a good thing. I don't think any of the authors are guilty of reinventing the wheel.
Similarly, I wrote own framework for asynchronous applications, even though Twisted exists. I like a lot of things about twisted, and I may borrow ideas from them, but I like my way better (largely because it's based on generators, which python didn't have when Twisted was invented).
On the other hand, I wrote my own template system, but have now found others (like kid and Genshi) that are even nicer. I'll happily use them, and I certainly don't mind that they made their own systems when earlier systems (including mine) already existed. In fact, I think the world is better for it.
None of that is reinventing the wheel.
Here's an example that is reinventing the wheel, and it's the sin I'm confessing:
Each time I sit down to write a web app, I come up with a new, half-baked idea about how the URL-mapping, handler dispatch, template, and redirection code ought to be structured.
I have a lot of ideas about how an app should be put together, and I've got a few labels (like "platonic") that I use to describe these ideas, but I don't have any example that really has a good implementation. Instead, there's lot of messy code with platonic ideas scattered about.
In other words, I'm not systematic about the overall framework, the way I am with storage and templates and tests and so on. That's what reinventing the wheel means to me: not being systematic.
Being systematic in your approach doesn't mean you can't improve, or that you're locked in. It just means that you have a set way of doing things as a default. If you encounter a better way later, you can change the default - but that's very hard to do if the default isn't documented anywhere, or at least encapsulated as code in a module.
I just did an inventory of all my web apps that I care about (there's only about 7, and half of them are tiny), and they're all structured in completely different ways. I made a spreadsheet describing the differences, and it's a mess.
My task now is to refactor across all 7 projects and come up with a standard structure - and then document it so there's no confusion about how to build things going forward.
