Even if you only build websites using CMSs, you've probably heard the word "framework" before.
You've probably also heard of a few famous web frameworks, including Ruby on Rails, Django and Bootstrap.
Many experienced web developers build websites using frameworks and often find them easier and enjoyable to use.
In this tutorial, we're going to explain what a framework is, and when you might use a framework.
If you are currently doing one of the OSTraining Coding classes, this information will prove especially useful to you.
If you are just using a CMS, this post will still contain some valuable insights, as many CMS systems can and are built using frameworks. For example, Drupal 8 is currently being built on Symfony and Joomla 3 is using the CSS framework Bootstrap.
What is a framework?
The goal of a framework is to allow designers and developers to focus on building the unique features for their project, rather than re-inventing the wheel by coding common, familiar features found across many websites and web applications.
A framework can be considered a pre-built template/structure that handles most of the repetitive or common features. As a result, unlike a CMS, a framework will probably not have a user interface (although this is not always the case, as Django provides an administration interface). Most of the activity will be done by writing code and interacting with different parts of the framework itself through code.
Often frameworks take a while to learn, but once you're familiar with them, they should speed up your development time.
When should you use a framework?
You can measure the need for a framework based on 2 broad topics:
- The level of customization you require: A good way to explain this would be to use an example. Say that you are running a company called Company AA with around 40 employees. You recently read a study that indicated how social interaction both in the workplace and online can drive innovation in your company. You want to employ this idea but you feel that using a public tool like Facebook or Twitter cannot address the solution of having a private and custom social network among your employees. You have also evaluated 'plugins' available for your CMS, but none of them quite fit the desired layout and interaction you'd like from your social tool (without a lot of hacking to get it to work). You therefore consider getting a custom development done for this project. As you can see, the above example indicates that the greater the level of customization, the more likely you would be using a framework. However, this also depends on point 2:
- The developers you employ: If you aren't going to do the development yourself, you will likely want to employ a team of developers (or a freelancer - depending on the size of the project) to do the work for you. Although a lot of developers do use open-source and freely available frameworks, some prefer to use their own custom-built internal frameworks and some choose to not use frameworks at all. Just like most communities that voice their opinions, the programmer community does so on many aspects, including the actual language used, the design pattern, the way the code is written and of course, multiple aspects concerning using frameworks. The choice developers make in whether or not to use a framework leads us to the next part of this blog, which is concerning the pros and cons of using a development tool like a framework.
5 advantages to using a framework
- Open-source: Most of the popular frameworks in many languages are open-source (or available to use for free). They also come with licensing that isn't restrictive and allows you to build commercial products using such frameworks
- Documentation and support: Although this can vary (if the language being used is popular and the framework has a lot of developers using it), you can expect that the framework will either have good documentation, good support or both at the same time. It is worth mentioning that “good support” is a subjective issue at times. Typically, paid support will almost always be faster and more concise, but this also depends on the level of activity within the framework - as a framework like Ruby on Rails demonstrates with a massive community, which is renowned for its welcoming nature and good support too.
- Efficiency: This could be considered the most vital reason why frameworks exist. They eliminate the need to write a lot of repetitive code that you will find being used in many different applications. These include, for example, user-authentication and commenting systems. On average (if you have sufficient knowledge using a certain framework) you can expect to build a project in much less time than would be achieved writing code without a framework
- Security: Typically, a framework is developed and tested by many different developers. It is extremely likely that many security risks are addressed and tested when the framework is being built. New security risks can also be addressed and fixed quickly. However, security can also be considered a con, as will be mentioned in that section
- Integration: If you are building almost any type of application (including a website) and you want to store some data, you will typically use a database. Just like a database, there also exists many other tools that link to web development. Many frameworks will thus make it easier to link to these tools and also communicate with them (for example, when “talking to” a database is abstracted away in a certain framework, making communication with the database much easier)
5 disadvantages to using a framework
- Limitations: Generally, you will not be able to do almost anything with a single framework. They are all restricted in some way, from coding paradigms to database designs and everything in between. A good way to work around this is to see what the framework is being used for by other developers in the community, as this will give you an idea of what you can achieve
- Learning bias: If you decide to learn how to use any framework from some programming language you are familiar with, chances are that what you learn will be somewhat different to the language itself. This is due to the fact that a lot of those repetitive tasks have been created in custom functions and other parts, which is why you will learn such things that may not have existed in the language lessons itself. Apart from that, you may also learn a lot of things that may be irrelevant to you whilst using the framework in real-life, but are necessary to grasp how the framework works
- Steep learning curve: Although this isn't always the case, most frameworks can be difficult to learn and and even more difficult to master. After some simple research into this matter, a university professor said that it will take about 2 years (with no programming background) to become familiar and comfortable using a language (Ruby) combined with a framework (Rails) (see here for details). This may not be the case when being self-taught or having years of programming experience, but I would say that even with experience, at least 3-6 months will be needed to become confident using any framework (based on continuous learning and practice)
- Cost: Frameworks require more development experise and experience than most CMSs. As a result, it can be more costly to hire reliable framework developers than reliable CMS developers. In my experience, the average project built with a framework is more expensive than a similar project built with a CMS.
Examples of popular frameworks
Below are some popular web frameworks (in no particular order) for different web languages. This is not an extensive list, as there exists many more options out there.
Over to you?
Have you built any websites using a framework instead of a CMS?
What were the advantages and disadvantages of going with a framework?
Share your feedback or any other experiences below.