Every web developer tries to save time and effort when making a website. The sign of a good developer is the ability to turn laziness into efficiency. Instead of doing the same boring thing again and again and wasting time, a good developer will create ways to do it again in a way that reuses work they've done before.
In making websites, it might be how a developer creates a way to handle web forms so that they don't have to manually escape and redisplay every time. A bad sign is just copying and pasting code. Over time, a good developer will develop a code library that they can reuse on many projects, saving time and getting websites done built faster.
Nowadays, a code library such as this that helps create a website faster in all respects (from the database all the way to the web pages that customers see) is called a framework.
A web framework handles common tasks that you run into when making a website and handles them in a consistent fashion.
Typically frameworks follow the MVC pattern:
- M = model (the data [usually database] and its manipulation)
- V = view (the interfaces [either for end user or code])
- C = controller (code that works with models and assigns views and their data)
So instead of putting your SQL, HTML, and code in the same file, these three are moved off to models, views, and controllers, respectively. Then they can be reused, and common handling of: database queries (usually with data objects and abstraction); web forms, HTML handling, data display; and common tasks like sending email, logging, etc. becomes trivial and much faster to prototype or build.
Disclaimer: this is the first article that will really indicate my bias in programming languages. If it does not apply to your situation, at least you'll know what frameworks are and what to look for, right?
I'm a Business Person, Why Should I Care?
Because if you're hiring someone to build your prototype or complete site, finding someone with the knowledge and practice of using a framework is going to save you a lot of money, because time is money. If the developer you hire is hand-writing all their SQL and reinventing form-escaping on your dime, you're wasting money.
The Good and the Bad
Not all frameworks are created equal. Each one was created with different goals and scope in mind. Some are very lightweight and some are robust and heavier in size. Some are simple and quick to get started with and some take a good bit of configuring and/or a steeper learning curve.
Investigating a handful of them and taking the time to try them out will give you an appreciation for the work that goes into creating one, as well as show you how much faster a site can be built. In the time someone could hand-code a prototype, a good developer could possibly create the entire application using a framework.
Which Framework Should I Use?
Depends on the programming language you're using and the robustness you seek.
- PHP Frameworks
- Python Frameworks
- Ruby on Rails, Rails Alternatives
- Perl Frameworks
- Microsoft .NET Framework
- Java Frameworks
I can speak for the PHP frameworks that I've used, being only two (CakePHP and Zend Framework), and a third which I've seen implemented and have familiarity with (Yii).
CakePHP is the first framework I ever used, in order to get PhotoGrinder built quickly so I could move on to my next project. It was easy to learn due to the nice tutorials and good documentation. It has support for reusable components created by the community, allowing you to add functionality without reinventing the wheel.
I recommend it, even if you just have a pet project in mind and want to try it to get you used to frameworks. The Cake developers are constantly improving and releasing updates, so it's not some stale, one-person project.
The only gotcha I had with it was learning that debug level 0 (production mode) does not update your model cache if you make db changes. Once I learned that it was a piece of "cake".
Zend Framework is a large, robust codebase that can be used in many different ways. Its strong point is the backing of Zend, and that it can be implemented as a whole or in parts depending on your needs.
The ramp-up to get started is a good bit steeper than other frameworks, due to the concept of "there's more than one way to do it". This flexibility is an advantage, but with that comes more difficult to find the documentation on what you're trying to accomplish. It's like a box of Legos where you know you can create great things, but you have to search to find a blueprint for something very common, or go through a good bit of trial and error to get fancy.
One problem I had was in order to get forms to look really good and add more interaction, I had to create my own Decorator class to get the right HTML hooks so I could style it well, and still even then I tend to have to use jQuery to put things in certain places. I may be doing it wrong, but it's the best I could do with what I had. I didn't have to even use ZF for my forms, but I wanted to take advantage of the power.
Yii is a very lightweight, powerful, and capable, and similar in many ways to CakePHP. It's easy to get up and rolling, and even has a command-line utility to auto-generate code for your database actions. It has support for multiple environments (like dev and production) and support for partial and full-page caching. It gives the feeling that the developers have solved some real-world problems with this, so it's reliable for your large project. Another great thing is it has extensions like CakePHP for adding common functionality.
In the June 2009 issue of PHP Architect (issue can be purchased individually for $5), they discuss 5 frameworks and their strengths and weaknesses. It's a good read. Even though Yii and Cake aren't in there, you can't blame them. There are quite a few PHP frameworks.
What framework are you using? Comment below. Please mention the programming language your framework is for and how well it's working for you.
Next post: just for fun