Drupal

PHP: Use associative arrays basically never

The other day I was working on some sample code to test out an idea that involved an object with an internal nested array. This is a pretty common pattern in PHP: You have some simple one-off internal data structure so you make an informal struct using PHP associative arrays. Maybe you document it in a docblock, or maybe you're a lazy jerk and you don't. (Fight me!) But really, who bothers with defining a class for something that simple?

But that got me wondering, is that common pattern really, you know, good? Are objects actually more expensive or harder to work with than arrays? Or, more to the point, is that true today on PHP 7 given all the optimizations that have happened over the years compared with the bad old days of PHP 4?

So like any good scientist I decided to test it: What I found will shock you!

Continue reading this post on Steemit

Larry 30 June 2018 - 3:59pm
Best practices are contextual

Articles, blog posts, and Twitter debates around "best practices" abound. You can't swing a dead cat without bumping into some article espousing the benefits of designing and building software a certain way. (Side note: What kind of sick person are you that you're swinging a dead cat around? Stop that! You're desecrating the dead!)

Larry 23 August 2017 - 5:51pm

New Drupal, new Platform, new PHP, new year

Submitted by Larry on 31 December 2016 - 12:19pm

OK, well, it took a while, but I've finally gotten my blog off of Drupal 6. :-) Welcome to the new and improved Garfieldtech.com! My blog is unsurprisingly rather bland, as it's, well, a blog. That made updating to Drupal 8.2 using the Drupal migrate module reasonably easy. It wasn't hiccup free, and a few not-yet-updated modules got lost along the way, but it wasn't an epic struggle, either. There were only two major hiccups:

HTML Application or Network Application?

Submitted by Larry on 19 May 2016 - 1:45am

There has been much discussion in the last few years of "web apps". Most of the discussion centers around whether "web apps" that do not degrade gracefully, use progressive enhancement, have bookmarkable pages, use semantic tags, and so forth are "Doing It Wrong(tm)", or if JavaScript is sufficiently prevalent that a JavaScript-dependent site/app is reasonable.

What I fear is all too often missing from these discussions is that there isn't one type of "web app". Just because two "things" use HTTP doesn't mean they're conceptually even remotely the same thing.

Moving to a new Platform

Submitted by Larry on 2 May 2016 - 9:02am

After my last post, a number of people asked if I was leaving Drupal all together. Perish the thought. :-) However, after a decade at Palantir.net and the five-year Wagnerian Saga that was the Drupal 8 development cycle (complete with singing), I have been asking myself "What next?"

Well, what do I like to do? I like to build. I like to teach. I like to make things better. I like to work with smart people, as colleagues, as community partners, and as customers. I want to be able to have an impact in making something better for other people.

To that end, I am pleased to announce that today is my first day as Director of Runtimes, Integrations, Engines, and Services for Platform.sh.

The end of an era

Submitted by Larry on 22 April 2016 - 1:06pm

Today is the end of an era. After just over ten and a half years, this is my last day with Palantir.net.

The past decade has seen Palantir grow from a company of 5 to a company of over 30. From a company that wouldn't touch the GPL with a ten foot pole to a strong advocate for Open Source, Free Software, and Drupal in particular. From a company that did mostly subcontracting work for design firms to an end-to-end soup-to-nuts agency. From having two desktop screen sizes anyone cared about to an infinite scale of screens from 3"-30". From a world where IE 5 for Mac was considered a good browser to one where once again, the latest Microsoft browser is actually good. (Everything old is new again, I suppose.)

After ten years with the same company (which in Internet years is about a millennium) I certainly have stories. There's plenty I could say about Palantir, most of it good. :-) In the end, though, there's one thing in particular that has kept me here for so long.

Palantir.net is the kind of place that has your back.

Giving Back in 2016

Submitted by Larry on 23 January 2016 - 5:18pm

Three years ago, I ended 2012 with a call to the Drupal community to Get Off the Island. Mainly I wanted to encourage Drupal developers to prepare themselves for the major changes coming in Drupal 8 by connecting with other PHP projects and with the broader community, and called on people to attend non-Drupal conferences in order to visit and learn from other communities.

Drupal 8: Happy, but not satisfied

Submitted by Larry on 3 December 2015 - 1:55am

Two weeks ago (hey, I've been busy and trying to sleep for once), after 1716 days of work by more than 3312 people the Drupal community finally released Drupal 8, the latest release of the best community-driven web software in the world. The blogosphere is already filled with congratulatory blog posts celebrating the immense accomplishment, and deservedly so.

A number of people recently have asked me how I feel about Drupal 8's release, especially around the PHP community. Overall, my answer has to be that I'm happy, but not satisfied.

Why I speak

Submitted by Larry on 7 November 2015 - 4:51pm

A few weeks ago I gave a keynote presentation at PNW PHP in Seattle. It was the second time I'd given that particular talk, Eating ElePHPants, a quasi-history and lessons-learned of the process of rebuilding Drupal 7 to Drupal 8.

Overall reception was good, and afterward I was appraoched by a woman who was trying to push for better development practices and refactoring a legacy code base at her company. We've exchanged a few emails since, as she goes about trying to subvert her company's development process for its own good to introduce testing, refactoring legacy code, decoupling, and other concepts that many of us on the conference circuit take for granted.

In the course of that email conversation, she had this to say:

When I first started with this entire effort about 2 months ago, I thought I will never succeed, and I thought I had set myself up to failure - until I heard you speak about your experience. Your talk was highly inspiring and got me excited to invest more time into what I was doing and I believed in myself for the reasons I chose this effort.

And later...

All the tech talks helped me realize that I can get somewhere, made it seem within reach, but you and Adam Culp [who also gave a session on refactoring] left me inspired.

Visiting other islands this fall

In case you hadn't heard yet, Drupal 8 RC 1 is out. And there has been much rejoicing! I'm going to save my own lengthy celebration-and-thank-you post for the 8.0.0 release, so for now I will just point everyone at Campbell Vertesi's post and say "what he said!".

But it's also a good time to consider the impact that Drupal 8 has had on the PHP community. The "off the island" movement has grown large, and people outside of Drupal are echoing the same message. In fact, not one but two conferences this fall are actively trying to build bridges between PHP sub-communities: ZendCon and php[world].

Larry 8 October 2015 - 2:49pm