Recently, I shared a guide for auditing, reviewing, and improving a Drupal module. In this guide, I suggested that developers experiment with the `drush generate` command, which uses the Drupal Code Generator to help gain an overall understanding of the potential architecture of a Drupal module. I decided to put my recommendation to the test by generating an example module using the Drupal Code Generator library. I’ve shared the results in a sandbox module on Drupal.org, called Drupal Code Generator Example.
Using code generators is new to me. Generally, my approach to module development is to find some example/template code, cut-n-paste the code into my project, and then customize the code as needed. I rely on my existing code, core, and the Examples for Developers module for my example/template code. When learning and reviewing a “Drupalism,” an API or concept, I also google for documentation and blog posts. I’m hoping the Drupal Code Generator library (aka the `drush generate` command) will become another tool in my toolbox when building a Drupal module.
Feel free to browse my Drupal Code Generator Example module to gauge your level of understanding of a Drupal module’s architecture. Now, I want to share some of my notes, recommendations, tips, and conclusions.
Some essential notes
Below are a few quick but essential notes about the output of the Drupal Code Generator.
First, generated examples are not always working code. There is a reasonable assumption that developers will review and customize the…Read More