Table of Contents
- Backup your database
- Check my code out of Github, or create a module directory
- Create a project info YAML file
- Create the necessary subdirectories
- Write the code to display your block
- Clear the caches
- Enable the module
- Place the block module
- See the custom block on your website
- The biggest problem I encountered
- The source code
In this tutorial I’ll demonstrate how to write a simple Drupal 8 “block module.” By this I mean that I’ll show you how to write a simple Drupal 8 module that will display output in a block. When you’re done you will have created a new block that you can place in one or more theme regions.
I had never heard of the term “Yoda Conditions” until now, but I have seen them in some Java code where programmers put the constant first in an effort to avoid null pointer exceptions.
This is the Index entry for recursion in the third edition of Programming in Scala. :)
Famed programmer Joe Armstrong passed away this weekend. He created the Erlang programming language, based on the actor model, and without using Google, I’m pretty darned sure that Erlang had an impact on Akka, the very cool actor library for Scala. Here’s an article Mr. Armstrong wrote some years ago, titled, Why OO Sucks (OO as in OOP).
I don’t recall hearing of the words “reify” or “reification” in my OOP years, but that may be because I studied aerospace engineering in college, not computer science. Since learning FP I often see those words, so I thought I’d try to understand their meaning.
The short answer is that the main definition seems to be:
“Taking an abstract concept and making it concrete.”
For the longer answer, I found the following definitions and examples of reification.
“Write shy code — modules that don’t reveal anything unnecessary to other modules and that don’t rely on other modules’ implementations.”
~ Dave Thomas
“The sooner you start to code, the longer the program will take.”
~ Roy Carlson (which I saw in this tweet)
In general, I’m a fan of that quote, meaning that the harder the problem is, the more I like to find a whiteboard or some index cards to work through the problem that way before I start coding.
“Strive for beauty and elegance in every aspect of your work.”
Back in the 1990s I was fortunate enough to work for a very smart, energetic man. In a way, working for him — or at least in the position he gave me — helped change the trajectory of my career into what I wanted it to be.
Skipping 99% of that story ... one thing he did exceptionally well was troubleshoot problems, and troubleshoot them very fast. I didn’t know it at the time, but he was using something called The Scientific Method. After observing him for a while, I saw him repeat these steps so precisely that I thought he must have them on a tattoo on the inside of his eyelids:
- Observe some feature, in our case, a bug
- Hypothesize a model consistent with the observations
- Predict future events the hypotheses should yield
- Verify the predictions by making further observations
- Validate by repeating