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 was just reminded of Rubber Duck Debugging. From this Wikipedia link, “The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck.” For me, my rubber duck is Albert Einstein.
“Besides a mathematical inclination, an exceptionally good mastery of one’s native tongue is the most vital asset of a competent programmer.”
~ Edsger Dijkstra
Dan Bricklin, inventor/creator of VisiCalc, the first spreadsheet program for personal computers, has created this page of historical notes and images about his work. His work came long before my interest in computers and programming, so I enjoy reading about it from a historical perspective. He shows a TI calculator and very large state diagram on this page. I remember seeing calculators like that in stores, and the work he put into the state diagram looks like a modern mind map.
If you’re into history, it’s all very cool.
“Years ago I knew little, but was comfortable using things I didn’t understand. Now I’m experienced, I fear things unless I understand them.”
“The honest answer to almost any question in software development is, ‘It depends.’”
Eric Evans, author of Domain Driven Design
Note: This is a post from 2007 that I just updated a little bit because I think there’s still some value in it.
A lot of people have written to say that it’s unfair that I think developers should never say “I’m 75% done,” or “I’m 90% done.”
So, to explain myself, here’s why I think you should never use a phrase like that:
“Programming is similar to golf. The point is not getting the ball in the hole, but how many strokes it takes.”