Skip to main content

Actions, Commands or Services?

Today I started to write a new class and was trying to decide what to name it and what pattern I wanted to follow.

Option 1:

class StoreInformationDownloader {

  public function download() {
    // ...
  }
}

Option 2:

class DownloadStoreInformation {

  public function execute() {
    // ...
  }
}

Option 1 is a typical Service class.

Option 2 follows the Command or Action pattern.

Which would you choose?

Was this interesting?

Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.

About me

Picture of Oliver

I'm a certified Drupal Triple Expert and former Drupal Association staff member with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.