Most of the beginners and, sometimes, even more advanced programmers, want to develop everything from scratch because they want have control over the every aspect of their application. I entirely understand this tendency. When you learned how to program and you can code nearly anything you want (this relates more closely to scripting languages like php, perl, js etc), you start to do something global. Something that will change the world. This may be a new CMS, a new framework, new blog of e-commerce engine. And when you start this, you want to code it in the most efficient way, optimizing every little thing: every function, every SQL query. At the same time, you want to reuse the code you’re writing. So you tend to create more general solutions than you really need. And this slows down the performance. And again you go into optimization, limiting the possible uses to some extent.
Finally, if you finish your application, it may be faster or better than similar ones (however, usually it is the same or worse), but remember how much time you spent developing it. Yes, you’re proud of yourself – you’ve created your own DB abstraction layer, that handles SQL injections in a very smart way. You’ve also developed your own ORM engine, that goes nicely with your DB abstraction layer. It is quite likely, that you’ve already created your very own template engine and a nice JS library that makes animation very easy. Great job, my fellow programmer!
Now let’s stop for a moment and look back. Why you’ve started developing all that? Say you wanted to create a brand new blogging engine, that is better than WordPress. You’ve spent several months (I can’t believe you’ve created nice DB abstraction, ORM and template engine in a week) to develop all that stack. And all you got is just another blog engine! Yes, it is cool and is capable of doing hundreds of things. You’ve even thought of the external API, so you can send SMS to be automatically published on your blog. But actually that’s just a blog!
Do you really think that the final result – blog engine was worth 2 months of the hard work and sleepless nights? If you answer “yes” and you haven’t got a feeling that something is wrong, then then you’re either mega-guru and develop only facebook- and google-scale projects or just a beginner who is still very proud of himself that he can code anything and you want to overemphasize this.
I think, every experienced developer was at that stage. I was there too. Moreover, I was there quite long and I regret of this.
By this time you may be quite bored and start thinking – what all that story has to deal with the framework. Actually the problem described above when you develop everything from scratch occurs when you don’t use any frameworks.
So what is the framework? Basically it is a set of libraries/classes, tied together that speed up the development of a certain type of applications. For example, MFC (Microsoft Foundation Classes), Qt, wxWidgets are frameworks that simplify the user interface development. It obvious that you should not draw 6 states of the button and change it on different events when it comes to placing the button on some form. You just use the ready-made class. But when it comes to the web-development, some developers think that they don’t need the ready-made (and well-tested!) DB abstraction layer, proven authorization classes. They want to develop it themselves. As a result, we often see low-quality and buggy applications. On the other hand, using frameworks does not necessarily gives you the excellent code, but it definitely helps you to get where you need much faster.
When you utilize good framework, you automatically get proven solutions in different spheres – DB connectivity, unit testing (most of frameworks provide tools for this or make it more simple), authentication, users and templates management. In addition, you also get a number of widgets, ready-made components for the problems you even don’t know about at the moment you start coding, but which usually come up during the development – caching, JS and CSS minimizing and publishing etc. Finally, you also get a bunch of extensions for a variety of tasks: RSS creation, CAPTCHA solutions, autocomplete widgets, treeview, drag&drop components to name a few.
The problem with framework usage for scripting languages is that they are quite simple and lots of developers don’t want to learn complex framework in order to achieve some simple task. And they are right… as long as their task is really simple. I think, “simple” is something that soesn’t require heavy DB usage, caching, user management, web-services integration and has very basic MVC implementation. That’s a simple homepage. All other projects should be developed with frameworks because that saves time and allows you to achieve better result.
But there is a little problem here What framework is “good”? I wrote about this in one of my previous posts where I explained why I chose Yii as a PHP framework for my project. Selecting wrong framework may result in project failure, so please refer to that post to see how I did that, maybe you’ll find that approach reasonable and join us in Yii community
And the last question I want to discuss here. The quality of code. I believe that using a framework with good design helps you to create better-structured applications that can be easily managed and supported. And the quality of code… I think this is up to programmer. It is definitely easier to create good application with properly designed framework just because you follow it’s patterns. However if you ignore the framework’s ideas and continue to create classes with static methods instead of simple functions, the framework is not very useful for you
Frameworks are good, but you should clearly understand what are they doing and use them only when appropriate. As a rule, framework provides a set of generic tools that simplify creation of any project. Key work is any. These techniques give good result for a standard use. However when it comes to some specific things, especially if they are very demanding in terms of performance, it’s time to evaluate your tools from the point of view of this specific project.
Consider you have a framework designed for a web 2.0 applications. It works well for the most of the projects you create. However you’ve got to build an SMS portal. Unlike your usual applications, this doesn’t deal with HTTP a lot, it uses it’s own protocol. So 80-90% of your favourite framework’s tools will be useless here.
If you’re building very large application that will be working under the high load, you should evaluate your framework and either reconfigure it or refuse from using it at all. Most of the great websites like facebook, for example, don’t use standard frameworks, but in order to become “facebook”, you should gain popularity and using the framework for your first version ill bring you to the marketing and launch much faster and you’ll start earning money.
Similarly, if you’re building the business-card-like page, using the framework is a bit overkill
- Use frameworks because they simplify your development, help getting better code and simplify documenting your solution (framework documentation is already written!)
- Choose framework very carefully!
- When solving non-trivial tasks and develop extremely large applications, re-evaluate your framework’s features and decide if it really worth using it there.
- All above is my own opinion, formed during the 5+ years of everyday web-development. Maybe this is not the absolute truth, but I believe it is somewhere near it
- Example with SMS portal was for illustration only, I’ve never developed ones and don’t know which protocols are used there. I’d be thankful if someone of my readers clarifies this.
And what do you think about it? I’d be thankful if you share your thoughts in comments. Thanks!
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.