1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3.50 out of 5)
Loading ... Loading ...

Building the best application…

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!

…but is it really brilliant?

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.

So what is the framework?

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.

Use frameworks!

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.

Choosing the framework

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 :)

When you should not use the frameworks

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 :)

Summary

  1. Use frameworks because they simplify your development, help getting better code and simplify documenting your solution (framework documentation is already written!)
  2. Choose framework very carefully!
  3. 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.

Disclaimer

  1. 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 :)
  2. 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.

Share this post with a friend Share this post with a friend

2 Comments

  1. Anatoliy says:

    To select framework its most difficult task. For example using different framework for different sites (projects) can be just lose time; for another projects where are customer what everything without frameworks you can’t use framework.

    I agree that write own framework\cms its just lost time especially when you doesn’t know how work and how developed another frameworks. More useful – add functionality to framework what you use.

  2. Konstantin Mirin says:

    Yes, sometimes customers want it to be written from scratch. However this rarely has some concrete reasons. They just want everything to be custom-designed. But I have a successful experience of changing customer’s mind on this :) For example, one customer wanted the JS treeview to be designed from scratch. I showed him that utilizing YUI or ExtJS means much less money and much more quick. At the same time, the quality is the same of even better :)
    So when you come across with a client who wants “from scratch”, just negotiate with him and explain why framework is a better choice (sure if it really is a better one!)

Leave a Reply