Why Frameworks Are Better Why Frameworks Are Better

Are you a person who dislikes frameworks?  Or are you a person who loves frameworks?  Or are you even a person who isn't quite sure what a framework is?  The following article will discuss the pros and cons of frameworks and the common downfalls that people fall into.

I'm not sure if it's only people I meet or a world-wide thing, but it seems people do not like to use frameworks (at least at first).  At my work, we use them on every new project.  So, when a new hot shot developer joins our team, we inevitable get to have the battle of "Ugghh, I don't want to use a framework I want to code my way and only my way".

If this is your typical response to frameworks, I suggest you continue to read and let me enlighten you on why we live and die by our frameworks.


Advantages of Frameworks

  1. Segregation of code and design.  All frameworks that I have ever worked with follow the Model View Controller (MVC) standard.  This is where we segregate data access, display, and logic into three different areas.  By doing this it allows us to focus on each part independantly of each other or even different team members.
  2. Simplification of accessing data from the database.  Most frameworks encapsulate the way we access the database.  By doing so, it allows us to easily port our application to a different database platform with minimal work, potential none if you haven't built custom queries!
  3. Results returned from the database are more usable.  Once a framework encapsulates access, it also formats our results for us into nice usable key/value arrays.
  4. Built-in features that save you hours of time.  Ever written your own pagination?  I know I have and every time I struggled with getting the start and end, the page count, next/previous, etc...  I always managed to get it, it just took a bit more time and a lot of testing.  My favorite framework has built-in helpers for pagination.  You simply need to query your data using that helper and it takes care of the rest.  2 to 4 hours of work has now become 5 to 10 minutes of work, even 1 to 2 minutes once I've memorized the syntax!
  5. Built-in features that you don't need to test.  Like the above pagination example, once I've implemented it I'm 100% confident that I do not need to spend the same amount of time testing it oppose to if I wrote my own.
  6. Helper classes to assist with creating design.  This also makes our code timeless because as HTML standards change, we don't need to update all of our code, just the helpers that draw them.
  7. Re-using code and objects.  Obviously, this is not limited to frameworks, if you build an OOP (Object Oriented Programming) application properly you can re-use your code as well.  However, with a framework and an application that has been planned properly, it becomes so much easier to re-use objects with minimal effort.

I am only scratching the surface with the above 7 advantages.  There are literally hundreds of more advantages.  In fact, if I attempted to list them all out, I could probably finish building an entire application with a framework in the same amount of time!  Feel free to share your favorite advantages of frameworks that I have not listed.

Disadvantages of Frameworks

  1. Learning curve.  Understanding the Model View Controller (MVC) takes some time, as well as learning the syntax to access data, draw elements, etc.  If you have a strong OOP background, this should be easier to understand.
  2. Complex things will take more time.  This disadvantage and the one below almost made me give up on frameworks.  After understanding more about the framework, I was able to understand how to overcome these obsticles.  The main reason that I did not give up on frameworks was the time gained VS the time lost was simply no comparison.  I saved 100s of hours and only lost a few.
  3. Even some simple things that you've done a million times without a framework can be more time consuming.  Having said that though, again once you learn the tricks, you will be knocking these things out the door 10 times faster.

In case you are curious as to what my favorite framework is, it's hands down CakePHP.  We've been using this now for almost 2 years and love everything about it.  It makes doing SEO work easier, creating forms, validating forms, all of the repetitive tasks that we do on a daily basis are now 10 times easier.

In some future tutorials, I will discuss how we take advantage of CakePHP and use it to our advantage on a daily basis.  As I come upon them, any difficult issue that falls into disadvantage number 2 or 3, I'll attempt to post an article about it to ensure no one falls into the same trap.

I encourage you to provide me your feedback on why you love or hate frameworks and what your favorite or least favorite frameworks are.

Published on Feb 17, 2009

Tags: CakePHP Tutorial | frameworks | Theory

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.

Tutorials

Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.