Do You Need A Framework?

I recently wrote a post where I discussed the reasons I believe it is okay to use frameworks in professional development environment. Most people seemed to agree with the sentiments I expressed there but a large chunk of them did not. Overall I still maintain that re-using code is a no brainer, but I wanted to dive into a little more detail.

One of the most common issues raised about frameworks is that they put your application on rails. In other words, the framework dictates the way you write the rest of your application and it locks you into that configuration for a potentially long time, if not forever. I felt like most of those making this argument were being a little dramatic but I don't completely disagree.

Frameworks do definitely influence the way you write much of your application. Continuing with the example I used in my article, AngularJS very much directs you to write code using a particular pattern. This makes it difficult to change your application later on if you wanted to switch frameworks.

In my defense, the article wasn't really about how easy it would be to switch from one behemoth framework to another, but about how easy it is to get help and support for a framework that is popular and open source. Setting that fact aside, do these guys have a point? Is it bad to use frameworks because you should always be able to completely refactor your entire application on a moment's notice?

Well, one thing I've advocated from the very start of this conversation is that you need to do some research. I did not intend to imply that anyone should dive into a framework without doing any learning first. It's important to ask yourself some questions before making a decision like this.

Will you really need to totally refactor your application later?

Unless you're putting together a giant enterprise application that is expected to have tremendous longevity and refactorability, then I say no. 90% of the applications I've developed do not get a version 2.

I used to optimistically think that all the code I wrote was going to need refactoring at some point so I would go to great lengths up front to make that easy later. I later realized that all this extra work I was putting in up front just made me a much slower developer, which made my clients very unhappy as one might imagine.

Before starting a project take a little time and think about whether or not you'll really be coming back to make drastic changes to this application. If you decide that it's distinctly possible that situation might occur then by all means, make whatever choices are necessary to make your life easier later. However, if the chances are remote (as they are most of the time) then picking a great framework to code against will usually save you a tremendous amount of time.

Do you even need a framework?

A framework is not magic. A framework is just a pattern that the framework author has followed while declaring obvious places for consumers of his/her framework to place their own code. It's not usually much more complicated than that, despite workflows differing from framework to framework.

A framework is usually a collection of smaller libraries all working in tandem to create a similar experience throughout your whole application. It's definitely possible that the features you desire from a framework would actually be better utilized by pulling in those features' individual libraries rather than the entire framework.

For example, you wouldn't want to pull in all of Express just so you could render one single Jade template. Rather, the smart thing to do would be to pull in the Jade library itself and manually compile your one single Jade template. I actually had to do this in a single page application; I realized that I was only using express to render a single page. All my other calls to the server were actually being piped into a single library that I developed. I had no need for all the other stuff that express brought with it so I got rid of it.

Ultimately it depends on your individual situation. I feel that sometimes people create frameworks in an attempt to streamline something that is just inherently too variable to streamline. There are plenty of situations where keeping things simple and agile in your code is of the utmost importance and a framework may violate that requirement. However, I believe that is the exception rather than the rule.


Read more posts by this author.

comments powered by Disqus