Other way to develop with Drupal

I'm not the author of this blog post. The original author is Carles Climent, a good mate and better person. This is a translation of his original post. Please, let me know if you find any error on my translation.

About why I feel a strange

During the last year I being introducing myself into the Drupal community and I have learned a lot of my peers, add my two cents and share a lot of experiences with the rest. But when I go to events and I find really masters of Views, Panels, Features or Rules I feel almost as strange as a monkey of the zoo on the city. Because all of this tools, as much as I try to understand them, don't motivate me or interest me.

I don't use Views because I like to control the queries I write. Because when I search in the mysql-slow.log I want to optimize the most slow ones easily. I don't use Panels becauseI have an excelent [MAQUETADOR] peer, who likes details and don't want any extra HTML or CSS. I don't use Features or Rules because I hate bot the autogenerated code and the bussiness logic on the database. I don't use any of this because everything they offer I can do it with those two hands and a keyboard.

Of all those tools I don't understand anything but instead, I like to talk about encapsulation, cyclomatic complexity, semantic and abstraction, testing and refactoring. And when I talk about this, many people open their eyes wide and look at me weird and I get complex and think that maybe I have said something wrong.

And I have not. It looks like I wear a diving dress and I jist landed in a space ship. But is not me, is not me! It's the Drupal community who is wrong. All I say it's the ABC of our profession, I don't pretend to be the valencian Michael Feathers, but when I uncover the source code of some module or from the core, I feel nauseous and dizzy and I think I will throw up.

About testing in Drupal

If you are a Drupal developer, is possible that this testing thing has come to you only by hearsay or you practice it occasionally and surely you will do it at the end. If not, if you think testing it's the root of every development, the tool that allows us correctly design our code, our documentation and our safety net, then, you are one of mine.

Of all the Drupal developers I know, maybe less than the 20 % take testing seriously. And from that 20 %, maybe all of us we are doing it wrong. It's partly our fault and Drupal's fault.

Drupal has been written at random, following the PHP culture. For better or worse, the developers use to do like the kids and mimetize what we see. If there is gold around us, we create gold. If there is crap around us, we produce crap. And there is not too much gold to find in Drupal.

Have you ever tried to do unit testing in Drupal? If you haven't tried, I encourage to try it. And then you tell me how much time it takes to find an unexpected access to the database, with a drupal_goto(), with a t() function, when collecting arguments with arg(0), arg(1) or $_GET. And you will realize that everywhere the code is coupled to the database, the URLs, the core, other modules or to itself... You will see the amount of functions that return HTML, that do too many things at once and have too many purposes. You will see templates with bussiness logic and almighty preprocess with 350 lines. You will come face too face with the procedural programming and will desire to inject dependencis but you will not.

All these disadvantages will force you to carry the burden of testing to the integration tests, desperately slow and fragile, and at the end you will finish trying everything from the interface with clickLink(), drupalGet() and drupalPost(). But one day you will change a couple things from the interface and seven tests of seventy five lines each one will explode and you will strech your hairs, asking yourself why it's broken again.

About why and how I continue with Drupal

I realized all of this gradually, after reading some great authors I concluded that this TDD was something that was worth a try. This is how I started my story of TDD with Drupal, that became very similar to the story about the patience and fatigue, the elefant and the ant. After more than one year of collisions and feeling like leaving Drupal, I concluded that Drupal is an excelent CMS and worhts a try to continue using it in a lot of our websites, but if I want to use it as framework it will be with my own rules, with object-oriented programming, MVC and BDD.

The details of how I applied all of this will come in a future post.