A Cynical Thought on Coding “Standards”

I wub you, Drupal

Drupal: I wub you, I wub you not

As my facebook posts have probably suggested, I have recently got down ‘n dirty with the worlds best (or at least biggest) CMS. It’s really not at all comparable to many of the frameworks I’ve played with or contributed to in the past — that would be like comparing a luxury minivan to a “flat thing with four wheels underneath it.” Yes, it is a flat thing with four wheels, but so much more besides.

All of the usual critiques have some basis in fact and some basis in developer irritation. Drupal has long since reached the point where its breadth and depth commonly exceed the capability of individual minds to grasp them easily, and it is changing fast. While I could certainly spend some time griping and moaning about the many petty annoyances Drupal has caused me to date, its effectiveness and the enthusiasm of its proponents so far outweigh them that I cannot in good conscience do so.

So this is what I will gripe about instead: coding standards as a symbol of orthodoxy. If you’re interested, check out Drupal’s formal statement of coding standards. Many of these tenets are well thought out, popularly agreed upon, and many qualify as best practices. If you happen to like being chided, some bright young coders put together a module named, in an egotistical but daring move, simply “coder” — a module whose purpose is to scan your source code and tell you where you have failed to obey these standards. Despite the fact that Drupal is designed to be modular (i.e., you drop the module in and its just works), a large portion of these standards is justified as “fostering” code accessibility. Well and good, especially in consideration of my points about docblocks below.

How can these standards be put to use? Let’s consider one non-optimal standards enforcement case.

In this response to a rather inventive idea for a module…

…I see little evidence of following Drupal coding standards:

- docblocks not formatted correctly
- spacing and indentation incorrect
- typos in comments and variable names
- incorrect formatting of variable names and constants

I’m afraid this module needs much more work before it can be considered for full project status.

…we see standards compliance being used to reject an idea because of its superficial failure to meet Drupal’s coding standards. Moreover, this was an idea put forward by someone who clearly does not speak English as a first (or even, strictly speaking, as a second or third) language. Even MORE moreover, it was an idea I could *really* have used if it were implemented. (For fairness’ sake I should admit that I have no idea how meritorious the code for this module actually was; my objection here is only to the use of the coding “standards” to bounce an idea from entry.)

Acknowledgement: I believe Joachim’s response here is not snotty, as it may appear on the surface, merely frustrated. If you want a dose of snot, visit Symfony’s forums — and bring plenty of kleenex.

So, let’s assume we strictly follow (for instance) Drupal’s docblock imperative — not a bad idea, one would think. EVERYONE knows that commenting code is ALWAYS a good thing, right?


// noteresource.inc
/**
* Callback for creating note resources.
*
* @param object $data
* @return object
*/
function _noteresource_create($data) {
global $user;

...code....
}

Okay, so what useful information does this docblock convey?

  1. That _noteresource_create's purpose is to (gasp) create a note resource.
  2. That the parameter $data must be an object -- in other words, "this parameter *might* be anything so long as it is expressed through an object*
  3. That the function returns an object -- which could, again, be anything (though we may presume it will be a noteresource-y type object)

This style of documentation, which is pervasive throughout the drupal codebase, is empty of information. We can almost always tell what the function does based on its name, so documenting the function's purpose is redundant; on the other hand, arrays and objects are so ubiquitous and so amorphous in PHP that indicating them without detailing their structure is 100%, absolutely, completely worthless. As always, the PHP recourse is to either a) dig into the code or b) call print_r an awful lot.

My other major standards gripe has to do with indenting and brackets. The Drupal standards (which I have no intention of obeying; I will use the Grammar Parser to achieve compliance when the time comes) are very specific about using 2 spaces for indents, not 4, and using hanging curly braces. This tends to result in rather unfortunate tangles of nested array definitions, difficult to read logical constructs, and (if you'll pardon me for being snooty for a moment) a very mushy aesthetic. It is important to remember that every ugly piece of code has a beautiful piece of code hidden inside it, waiting to be set free...

These two major gripes bring me right back to TimToon's very apt rant on this topic. I hear ya, man -- I hear ya.

Tags: , ,

Dream Diary: May 23rd, 2011

Zombie Apocalypse by the GreatSpoo

Zombie Apocalypse

Having been convicted of treason, I found myself locked into a detention facility in the downtown area of a bustling modern city. For days I watched the city through the window of my cell. Then, one day, I heard screaming and pounding feet — first in the streets below, and then in the halls of my prison. Fearing for my life, I hid in a closet in my cell. Three zombies broke down the door of my cell and sniffed around my room. Not seeing my, they eventually left, leaving my cell door open. I stayed hidden for hours… days… until the screaming and shouting and occasional gunfire in the city outside my cell gradually diminished into a profoundly uneasy silence.

 

When I finally left my hiding place and looked outside, I found the city was infested by zombies.

Roaming the blood soaked halls of my detention facility, I happened across another survivor. We quickly joined forces, scoured the building for food and supplies, and secured the premises, killing any zombie we found in our path. After a while, we began to feel safe — safe enough to plot an escape from the infested city.

Zombie Food Pyramid


We determined that the safest way out would be to sneak to a nearby subway station and follow the subway tunnel to the less densely populated suburbs, and from there to the safety of the countryside — this despite the common knowledge that subterranean tunnels and confined spaces are ALWAYS a bad idea during zombie incursions. We fought our way to the nearest station and managed to get onto a train when, sadly, two zombies caught hold of my ally and ate him.

Just before they turned on ME, a man appeared in a spacecraft of some kind (I believe it was actually a Federation shuttlecraft, but my dream was a little unspecific on this point) — not just any man, but General Zod from the Superman II.

General Zod to the rescue!

He dispatched the two zombies who were threatening me and whisked me up to his spacecraft.

The city was obviously a loss, he said, and the only option was to nuke it from space. He had the nukes necessary to do the job, but he didn’t have a delivery system for them — what he did have was a lot of pressure treated lumber. So, taking up a hammer and a saw, we began to build a missile launcher out of wood.

Dene Hager liked this post

Tags: , ,

“All That Crap Down the Hillside”

I was sitting in the office this morning, minding my own business, when I accidentally eavesdropped on Cathy’s conversation with her daughter LaRae.  Specifically, my keen ears picked up Cathy referring to my ongoing landscaping project as “all that crap down the hillside.”  I discretely shouted “be silent, you crazy woman!” and was ignored according to our longstanding tradition of Cathy not paying any attention to me when I shout things at her from a distance.

I should step back for a moment and explain: one of the reasons Cathy and I bought our house is that, while it has a conventional front on Lynn Street, it came bundled with a long, skinny plot of land (almost a half acre) that descends down a steep embankment and into the Squalicum Creek basin.  It’s a very beautiful and very polluted little landscape — and one of the principal reasons why we chose this house of all the places we looked at in Bellingham, back when we were on the market, and before the real estate crash.  This green space in the middle of the city makes me feel cheerful about negative equity!

Three Cottonwood Trees in the Squalicum Creek Valley

Wild Cherries and a Wheelbarrow

Wild Cherries and a Wheelbarrow

Ralph, Supine

In any case, I have been undertaking a long term landscaping project which involves clearing and partially taming the hillside about halfway down to the valley floor.   It’s a very liminal space, not suburb, not wilderness, but somewhere in between.  It’s infested with bindweed (calling it morning “glory” makes me want to holler about the injustice of it all), himalayan blackberries, and ivy, crawling with millipedes and salamanders, and littered with mouldering woodwork and nails from home improvement projects that have been discarded for half a century.  I love it — it reminds me of growing up.  Furthermore, I have grand plans — a staircase descending down to the halfway mark, a fireplace, a patio.  BBQs in summer, music in the afternoons and projected movies in the evenings.  In spring, the smell of skunk cabbage blooming — in summer, cottonwoods flowering — in fall, the smell of maple leaves turning into soil.  A world apart.

In the interim, however, it is kind of nasty, and I don’t believe Cathy actually considers it part of our property.  I am still hoping to convince her that this is a worthwhile project…  not just a bunch of crap strewn down a hill in the woods.

 

McNielsen Homestead, Hillside Project

Tags: , ,

Abandoned Elevator

Okay, so I confess here (as I’ve confessed elsewhere) that I have downright lousy taste in music. On occasion, this extends to horror movie soundtracks… in particular, I’m a huge fan of the band Goblin, whose work fueled Dario Argento’s Giallo works in the 70s and 80s. Goblin was an awesome band, no matter what anyone else says about them and their gross excesses (no pun intended). The main theme from Profondo Rosso is one of my personal favorites.

That said, the following snippet just came off the press — pardon me if it’s a bit rough. It’s very un-Goblin-ish, but it might do as transitional mood music for one of Argento’s movies.

Abandoned Elevator

I don’t know if “Abandoned Elevator” constitutes a permanent title — it’s just the phrase that came to mind 10 minutes in.

P.S. Yes, Michael. I do love dissonance a little more than I should.

Tags: ,

Dream Diary: April 16, 2011

Last night, I dreamed that I was at a ski resort when it was taken over by ski terrorists.  I caught an errant bullet in the head — it went in through my temple, a few inches above my left eye, and came out low on the back of my skull.  I was aware of lying on my back while some of my fellow hostages leaned over me.  “There’s no way we can stop that bleeding,” one of them said.  “Nope, at least bleeding to death in the snow isn’t too painful a way to go.”

But I didn’t die.  I could feel the blood pouring out of me, but I willed it to coagulate — and after I while, I pulled myself to my feet.  The ski terrorists, seeing how resilient I was, promptly forced me to help them accomplish some nefarious goal — I think they were looking for food in the resort’s staff lounges, but I’m not sure.  I cooperated but covertly, I did everything I could to slow them down and obfuscate their mission, and I managed to do it without them realizing it.

Despite the gaping wound in my head and the ridiculous quantities of blood I’d lost, I felt my strength waxing, and I knew that when help came, I would be ready to assist in overthrowing the ski terrorists.  But just before that happened, the terrorists realized that, if they were captured, they could be sued for having injured me.  Their solution was to shoot me in the head again.  “More thoroughly, this time.”

After that, I just dreamed of skiing long, perfectly groomed scopes, with blue runs rising above me towards the heavens.

 

Tags: , ,

The Guernsey Literary and Potato Peel Pie Society

The Guernsey Literary and Potato Peel Pie Society

The Guernsey Literary and Potato Peel Pie Society

Such a lovely little read.  I would say it’s the best little nugget we’ve cracked open for a year (not difficult, considering that our literary diet consists mostly of Madeleine Brent and Elizabeth Peters) except that it was probably only as good as Major Pettigrew’s Last Stand.  In any case, we found it a very enjoyable cross-genre read.  I would characterize it as a light tracery of romance over a very heavy background of World War II history, all very much in love with its settings and its cast of characters, and all expressed as a collage of letters, telegrams, and journal entries — a form of exposition that I could not have imagined being executed as gracefully as Schaffer (and Barrows) managed.

I had no idea that Guernsey was the setting for The Others — I’m a little sad that the film didn’t show more of its setting!  It looks like an absolutely beautiful place.  I would love to spend a week on these coasts.  Some day…

Fermain Bay on Guernsey

Mmmmm, tasty coastline...

I have only two slight complaints about the book: first, its conclusion feels abrupt; not that it rushes in arriving, but once it does arrive it is gone so quickly that I read into the Acknowledgments without realizing they weren’t part of the text itself. This may actually be an inverted form of praise: I simply wasn’t ready for the book to be done! It is also perhaps partly accounted for by the fact that the author, Mary Ann Shaffer, fell ill before finishing the manuscript; her niece, Annie Barrows, picked up where she left off and brought the book to completion. What a charming literary family they must be (and do notice, Annie is a bit of a hottie).

My second criticism is a bit more damning than the first, however. While some of the novel’s circumstances are extremely gritty and some of the text is appropriately hard to read, it did feel as though the warmth and cohesion of the protagonists occasionally escaped the feasible and became exaggerated. Some of the warm fuzzies simply felt a little… inauthentic. Isola Pribby, in particular, felt concocted and a little artificial, an idealized eccentric islander too sweet and kindly to exist in real life. I only had to use a little of my talent for suspending my disbelief — but, in a novel that was so otherwise pitch-perfect, it felt like a shame to me that I had to use that talent at all. Do note: I may be accused of cynicism. If you ever meet a real life Isola Pribby, please email me immediately and I shall promptly and with all haste amend my review.

Okay, now go read the book.

Tags: , ,