The view is a lie
the story
When you get introduced with Drupal, you get introduced with a powerful couple: CCK and Views. Now I assume you know both so no need to explain their awesomeness.
CCK has proven to be an unmissable part for pro Drupal development. It’s there right in the core of Drupal 7.
The views module is one of those modules which (almost) every Drupal developer recommends for rapid development of drupal sites. Most drupal sites can’t go without views, hell this site is living proof of me also using it. You can ”quickly” create complex queries and create blocks, pages and what not. Awesome right? Well, to a certain point.
so what’s wrong?
Let me some up some of the reasons to avoid views.
- Views make you, as a professional developer, lazy
- Most queries generated by Views are unnecessarily complex, slow and hard to alter.
- Clicking queries together with the views interface is not faster then writing the query by hand
- Templating of views is a nightmare. The views module generates way to many HTML for a simple CMS tool.
- When you get used to views you are tempted to use them always…and forever! Resulting in poor maintainable websites!
Now, of course, I am nitpicking and yes I do use them as well. Yes, it is cool when you need to quickly throw something together (take this site for example). Clients, however, expect more from you. They expect high quality and maintainable applications.
That last point is one of the biggest reasons to avoid a module such as views. If you run a proper development-test-acceptation-production setup, you are screwed. This is a common problem for Drupal websites, but using modules like views, which store loads of information in the database, make it that even harder to maintain,update or upgrade your applications.
You have to remember that the views module is supposed to be a query generator but it will also template the hell out of the output. Also, views can do more magic stuff such as; pagers, grid layouts, provide blocks, etc. All of these things can be made by you as well! It will give you way more flexibility. It allows you to create reusable modules and by being code, it can be version controlled and you avoid dependencies with some modules. I ran into this when installing the node picker for WYSIWYG for a site where I tried not to use views. Now I need it enabled, just for a node picker. Guess what I’ll be writing soon? :-)
what now?
Do yourself a favor and learn proper PHP and mysql and start building modules instead of building views. There are many advantages to this:
- You can define your own templates. Take back control of your output.
- Write efficient queries and use more complex sql features.
- Use version control on your modules. This makes it easier to rollout new features or fix bugs
- Utilize the _install and _update features of modules. Again for rollout of new features.
- Away laziness and start coding again!
- You know the inside outs of the written module, bugs are easier to track down.
conclusion
No, it is not bad when you use modules such as Views. It does not make you a lesser Drupal developer. It does however make you a lazy programmer and soon you’ll be a master in using clickable interfaces. Start wondering if that is what you are aiming for. Just remember that everything which is possible through the awesomeness of drupal interfaces is also possible through script. Remember that script still is easier to maintain and version control then databases.
This is in no way a bash against the views module, not at all. I took views as an example because it is probably one of the most used modules in the drupal community. When using such a module always think about the consequences and take some more time to think if it’s not a better idea to write it yourself. Go through the documentation on drupal.org and start learning. You might enjoy it.
For those who are super ‘Views’ users and got interested I will post some tutorials soon!
Tweet