Oliver Davies
bfa27dea9f
Some checks failed
Build and Deploy / build_and_deploy (push) Has been cancelled
Actions, Commands or Services?
773 B
773 B
title | date | permalink | tags | cta | snippet | |||
---|---|---|---|---|---|---|---|---|
Actions, Commands or Services? | 2025-01-06 | daily/2025/01/06/actions-commands-services |
|
~ | To Action or not to Action? I was writing a new class today and wondered whether it should be an Action, Command or Service. Which would you pick? |
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?