Fear (and respect) the framework
The past few months I’ve been working on building a relatively specific module for Drupal. Rooms wants to solve the booking problem for hotels, vacation rentals and B&Bs. Using Drupal to build it has meant that I had access to a wealth of generic tools. A DB layer, theming engine, date tools, querying tools, etc. My task was reduced to figuring out a reasonable solution for my specific problem and joining the dots to get it working.
As soon as Rooms was released we had several requests to turn it into a generic booking solution. Hotels and B&Bs book rooms by the night. They do discounts for single use. The rooms sleep a certain number of people and have a bed configuration. What if I want to book a conference room for an hour, rent a guitar out for 30 minutes, book a car, a ship, a yacht, a spaceship! Rooms, some suggest, should be a generic booking solution so it could then be adapted to any scenario. This got me thinking about the framework vs domain-specific approach.
The appeal of framework solutions - getting to the core, resolving the underlying issues, tackling the larger problems is undeniable. Who wants to fix a home when you can fix a town, a country - save the world! I am as guilty as anyone - my PhD thesis was titled Models for Agent-Based Systems and it was all about introducing generalized methodologies and modeling techniques.
Drupal is a great example of going down the framework route. It started as a CMS / Community tool and it is evolving into a generalized framework for building web applications (the CMS is turning into a mere example of what the framework can do). Along the way it is also feeling all the pains of having gone down that route. Confused users, developers often lost in a maze of possibilities, integrators trying to figure out whether it’s going to be a contrib module, a custom solution, contrib + custom, some of it in the theme, some in the db, etc. The more Drupal goes down the route of generalization the more the efforts to offer help, support and training increase - because those houses eventually need to get fixed in order to fix the town and save the world.
Now here is the challenge (as far as I am concerned). Up to a certain level frameworking is essential, beyond it is superfluous. It needs to stop and you actually have to solve the specific, mundane problem. Once a framework is in place at some point we need to stop building more frameworks on top of it. The risk of turning Rooms into a generic booking solution is that the distance from the specific problem would increase so much that we would then have to claw it back to re-adapt it to hotels. And what would we gain by the generic booking solution in a hotel setting? If a hotel owner saw it they wouldn’t recognize it as relevant to them. They would say “sure - this is a generic solution”, but I need one specific to hotels. One that talks my language and tackles all my very specific issues about “doubles used as singles” and “cots available”, etc.
Some developers might be happy - they would see the possibility to build on top of it. But are you really building on top - or against. Focusing just on hotels means also simpler code as the space of cases to deal with is reduced. With a framework do we end up with simpler code, easier to understand and fix or are we simply hacking a generic system to do something specific. Even Drupal - that has lots of very intelligent people building it at times feels that it is working against you and making you jump through hoops for simple tasks. More framework-style solutions would be adding more layers of complexity.
A framework that reduces the work for subsequent tasks, simplifies the process and leads to better code is in the right place. Overall, I think with Drupal we already have plenty of frameworks both in core and contrib. Not every module needs to solve generic problems - it can also simply tackle the challenges of a specific group of users. We need to fear the framework path - and respect the frameworks we have by using them as effectively as possible.
Disclaimer: I may well be wrong here ;-) I am hoping to get good pro and con arguments.