The benefits of building your own framework

Just do it as a challenge.

I am a big fan of the Symfony framework. I feel like it is the one PHP tool where you spend less time fighting the framework and more time building your application. But for the few times it doesn't do the things you want, you have to go through the documentation to figure out how things are done the proper way.

The good thing about programming, is there is more than one solution to any given problem. This is why it is hard to teach it in school. Teachers want their students to follow a specific way of doing things and for any deviation, you lose points.

In reality, there is no proper way to do anything. Countless of time we use methods that are frowned upon when solving problems. At the end of the day, we build applications that solve our problems. It doesn't matter if they are bad, who writes good code anyway?

It was inevitable for me to end up building my own framework and I had a few very good reasons to chose this adventure.

The best way to learn

There is no better challenge then building a very complex framework and making sure that it works as intended. Even geniuses don't wake up one day and build a masterpiece before noon. To build, you have to study the other stuff out there.

It is common to download the source code of a project and not know the first thing about how it works. But to paraphrase Einstein, the more time you spend with a problem, the more likely you are to find a solution. I downloaded Symfony 1.x versions and studied them. I studied how a router works. I studied how it supported adding other plug-ins. I studied how it created its amazing command line tool. These were things that you don't find in a tutorial.

I downloaded Symfony 2.x and did the same. I downloaded Doctrine. I downloaded jQuery too and read the source code like a novel.

Write better code

These are tools written by exceptional developers. You can only come out a better person after reading them. It is one thing to use a feature, it is another to know how it works in the background. Countless of times I read questions on Stackoverflow where the answer suggested to increase the memory limit when using Doctrine. If they understood how Doctrine worked, they'd know that maybe they are not using it correctly and that's why it is eating up all the memory.

Not every developer has a blog where they share their findings. Even those contributing to open-source sometimes never talk about the process they use. Reading the code is the only way to learn from those people.

And reading well written code, will help you write better code yourself.

No more updates.

Frameworks are written to support as many developers as possible. People can use it as they see fit, as long as they don't modify the core. This is a good and bad thing.

A good thing because, you don't have to worry about maintaining the framework. The creator will provide updates and bug fixes as long as the tool is relevant. When there is a vulnerability, all you have to do is update.

It is a bad thing because, it is risky to touch anything in the core. When I worked on Symfony 2.3 there was a small bug that turned POST requests into GET requests. I created a work around to deal with the problem. It worked for our case and that was the end of it. Only a year after, we updated the framework and they happened to have fixed the issue. Now my workaround was breaking the code instead of fixing, and was probably featured on the DailyWTF.

The good thing about building your own, is having the luxury to modify any part of the code.

Becoming a better writer

It becomes evident very quick that if you build something used by more then yourself, you will need a documentation. Writing is something I avoided as much as I could throughout my life, but it always came back to bite me.

Writing can be hard, but the best way to get good at it is by writing frequently. This very blog was started because when I read my own documentation a few month later, it made no sense to me. Writing something that last is the ultimate goal and this blog is proving to be useful 2 years later.

Becoming a leader

A lot of my developer friends have the technical skills to be leaders but lack the confidence to lead. You can't learn to lead by standing on the side line. No matter how many self development books you read, you can't lead if you don't put yourself in that position.

Building a framework automatically puts you in this position. You have to answer questions, you have to justify your choices, you have to turn down suggestions, you are the one making decisions.

Writing an application on which other developers will build their application is a great responsibility. You can only get better as you put yourself in this position.

Certainly building your own framework is a challenge, but there are many rewards. You get exposed to problems your common developer doesn't get to experience. Along the way you learn to write better code, and become better at communicating with your peers. It puts you in a leadership position where you have to make decisions that affect many people.

As a programmer, it is something to experiment with eventually. The sooner the better.


There are no comments added yet.

Let's hear your thoughts

For my eyes only