Disclaimer
Instead of writing a disclaimer at the end of the article or hide it somewhere, I want to start with some notices. This article is no excuse to write all complex systems yourself. In fact there is a lot of great code already written, that you could or should use. You also should learn the php core code as well, so you don’t rewrite functionality that are already build in the language. In fact this writing is about improving your own php skills.
Rules to follow
Lets start with some rules you should have in mind before you start reinventing. At first you should have some idea about what you want to build or what problem you want to solve. In my case I wanted to write a easy to use framework. Second you set yourself some goals you wish to accomplish. Than you start to analyze your problem and start doing some research about solutions from others.
Now the fun part begins. Convince your self you could do better than all the solutions that there already available and start programming. Don’t bother to write some technical design, because that spoils all the fun of creating something out of hobby, unless it’s one of your goals. While programming, try to use all things you know in your work, even when you just learned it. And keep in mind your original idea and the goals you have set for yourself; They have a strange way of shifting while you progresses.
Stop programming when you have proved your solution can work and review the code you have written. Than you can try to improve your code by refactoring, by writing better docblocks, adding extra features or by making it readable for others. All seems quite simple so far, but here is the catch. Most of the times you don’t prove your solution before your insight has changed or you have learned new things you wish you had build in. Than there is only one solution left; start over.
Starting over and over and ..
Restarting is no bad thing, it’s prove you really learned something. When you don’t have to rewrite your code you are probably the most skilled programmer there is or you just stopped learning. For all others I have some tips how to restart building your idea.
First check all, and that means ALL the solutions you have already build so far and analyze what you want to re-use. Check if your idea and goals are slightly shifted or if there still the same. In fact you follow the same steps you have done the first time, but you can skip the research part if you want. You probably restart a lot of times while you working on your idea, what brings me to the last and final rule: Never finish your work!
Conclusive
Before I started reinventing the wheel myself, I didn’t know much about objects, classes or template engines. As I improved my code and started over several times, I expand my database knowledge, learned the MVC and ORM model and how working with templates can help you separating php code and html. I even learned a little bit what tough choices frameworks had to make to keep it easy to use and some “do’s and don’ts” for better performance. Without trying to “reinvent the wheel” it would cost me a bit more time to understand the php language. And it wouldn’t be so much fun learning it.
Therefor, reinventing the wheel is great. It improves your skills and it helps you to understand and appreciate some of the software that is already there.
