Don't reinvent the wheel…

Jan 26, 2011 − Don't reinvent the wheel! Hmmm, are you sure? How many times have you already heard "Don't reinvent the wheel"? If you're a programmer, I guess you heard it a lot of times. But is it always a good advice? Even if it seems obvious to not reinvent the wheel, let's think about it a little bit more.

How many times have you already heard “Don’t reinvent the wheel”? If you’re a programmer, I guess you heard it a lot of times. But is it always a good advice? Even if it seems obvious to not reinvent the wheel, let’s think about it a little bit more.

The wheel: the perfect object

The wheel is a nice object, it does what it is supposed to do (to wheel), and it does it perfectly. But when we’re talking about software development, it seems that the analogy with the wheel is a bit flawed. What does “don’t reinvent the wheel” mean in software development? Litteraly it should mean: “don’t redo something which does the job perfectly”. There is something weird about that. Who can say that something is perfect in computer science? For sure, not me.

Generally, when someone tells this to you, he means that somebody has already done a similar work before you, and that you should be aware of this. If the project is big, lot of people already use it and the code is certainly well tested and fully functional, so you should consider to use or to improve it instead. This is often a good advice, but keep in mind that it’s just an advice! Sometimes, you should stop killing your imagination by always using things others have done.

Make informed choices

The keypoint here is to make informed choices, even if you’ll reinvent another (and perhaps a better one) wheel. Let’s take a concrete example from the PHP framework community. Sometimes ago, yet another PHP framework was created (I can’t remember which one it was), and the reactions on Twitter were all the same:

  • Yet another PHP Framework?!
  • Why reiventing the wheel?
  • One must be crazy to create another PHP framework!

The guy behind the framework was not famous and even if his framework was done for good reasons, nobody cared. It’s just another PHP framework which reinvent the wheel. Dot.

Two years ago, another guy started yet another PHP framework too. What a crazy man! At that time there was a lot of PHP Frameworks like symfony 1, CakePHP, CodeIgniter, … so creating another PHP framework seemed to be a bad move. Of course, he will reinvent the wheel! But I guess that if I give you the name of that man and his new Framework, you’ll change your point of view. At that time, it was Fabien Potencier which was creating the new Symfony2 framework.

And sometimes, reinvent the Wheel!

Symfony 1 was a good wheel, it was working fine and it did the job. But because of some conception mistakes (my dear sfContext::getInstance() for example), it was hard to make it evolve. So Fabien decided to write a whole new Framework from scratch. Yes, from scratch. A new wheel, but a better one. Fabien was aware of the problems of symfony 1, and that’s why he decided to make an informed choice: to reinvent the wheel with Symfony2.

Conclusion

IMHO there is 2 kind of people regarding the wheel problem:

  • People who always say “don’t reinvent the wheel”. Those should really think twice about it before. Sometimes, it’s a good thing to reinvent the wheel. Last week, Everzet wanted to write a good package manager for PHP, the next “PEAR”. And of course someone told him “why reinventing the wheel ?”. For that case the answer seems so obvious: because the existing wheel just sucks!

  • People always reinventing the wheel. Those should consider to make informed choices instead. Sometimes it’s a good thing to reinvent the wheel, but only if you know why you’re doing it.

If I had to summarize my thoughts on the subject, I could say: guys, continue to innovate and to be creative, based on what others have already done. We can learn a lot from our and others mistakes. To conclude: try to have fun when doing (web) development, and if it’s by reinventing a better wheel, just do it!