Friday, November 28, 2008

Why I'm begining to dislike frameworks

I've been having discussions with David and Dr Pep over the last few days about the pros and cons of development frameworks. This is probably a measure a my increasing level of cynisium but I found myself looking at a framework that T4 was looking at and thought to myself "what is this framework going to stop me doing?"

David raises the point of the productivity curve; in most cases when picking up a new library or framework doing the 'hello world' stuff is easy and your productivity is high. As you come across issues or want to solve more complicated puzzles your productivity drops as you struggle with the design choices of others.

I think one way in which these frameworks can be assessed is asking how much will it cost you to remove it? We're currently using Symfony, a PHP MVC framework, and it follows this pattern exactly. It's easy to get started, and doing easy things is easy, but when we want to stray off the beaten path, we get beaten ourselves. The documentation is sparce, and if we decided to use something other that Symfony, we might as well re-write our project.

Now, I'm not trying to start a Symfony bashing dialog, I'm just using it as an example. In fact, Milan makes the point that this particular framework is Open Source, and if we have problems, we should commit something back to the project. Which is the right way to view this.

It still doesn't stop me from having second thoughts about using a framework again. Give me swapable libraries everytime.

3 comments:

Unknown said...

When you assess a framework by removing it from your project, you only know how much this framework already has resolved for you. And Symfony takes care of lot of things, so it's not that surprising that you have to rewrite almost everything when removing it from your project.

I don't think that Symfony is easy to learn. Things can be managed in a lot of different ways with a lot of different configuration files and a rich API. But this makes it a very flexible framework which can be used in a lot of different projects. (once you know how to use it)

In my opinion a framework should be assessed if it's useful for a specific project and I think Symfony qualifies for most (rich) internet applications written in PHP.

Anonymous said...

Perhaps you should have a look at Agavi. It's a MVC framework for PHP that doesn't force you too much into using this or that or the otherLib. It's flexible and there's a v1.0 soon (when it's ready I guess, that is). IMHO Symfony and Agavi both share the same Mojavi roots, but Agavi tends to put more focus on freedom than on conventions over configuration.

Modules are configurable through XMLs, config files are compiled and cached, too. The best thing so far is the separation of actions, views and templates. There's not only an action and a view like in symfony, but a view, that sets the template. You can have multiple output types and multiple renderers (e.g. HTML output type by using the default PHP renderer). It's very easy to switch output types and renderers depending on routes etc. Pretty neat in comparison to other frameworks. You could easily not only write web applications, but also MVC command line apps or web services. If you have your business logic well organized using models, it's mainly a question of switching output types and their specific renderers (think WSDL, XML, JSON, whatever).

When 1.0 will be released, there should be a somewhat complete documentation (there's already something hidden in SVN if I'm not mistaken). If you want to have a look at the source, you can find the project at http://www.agavi.org/ - btw I'm not related to the framework, but after finding it a few weeks ago, I seriously think about contributing or at least heavily working with it (and therefore submitting issues or something to their trac).

About Symfony: I had the same feelings about it like you - first it's easy to get familiar with it (as all the new MVC frameworks in different programming languages are somewhat similar), but then you trip over some small flaws that aren't fixed that easily - so you either live with it, start working against the framework or have to think about patching it. Neither solution being too elegant. Nothing like this in my first weeks with Agavi. Just remember, that it's not yet as mature as symfony (esp. if you compare the available documentation, community feedback and plugins/whatever).

Robbie said...

I guess it's my fault for dropping names, but thanks for the comments.

@Treur, I agree that a framework should be assessed on it's usefulness, mine is more of a caution that someone needs to play devil's advocate to point out flaws and risks. I've seen it too many times where one person says "this is great, let's use it", and everyone else just goes along with it.

@Anonymous, I certainly am more in favour of a supportive framework like Spring, rather than one which forces you down certain routes and is difficult to extract. That said, I always enjoyed building Rails websites, but I think I knew the limitations better there and was making a conscience decision.

Thanks again