Abstract Base Class versus Service with Queue API I'm trying to figure out the best way to structure a custom module that uses the Queue API in D8.  I'm new to D8 and a bit rusty with OOP so forgive me if I'm breaking some recommended design pattern here...

I created a single custom module where multiple different queues need to process items differently, but each queue has common functionality that they may need to use between each other.  So my question is, should I create an abstract base class that extends QueueWorkerBase, make processItem abstract, and then add common functionality to the base class?

Something like this:

In src/Plugin/QueueWorker/ProcessQueueBase.php

abstract class ProcessQueueBase extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  abstract public function processItem($data);

  protected function doSomethingCommon(){
    // Some common logic
  }
}


In src/Plugin/QueueWorker/ProcessQueueOne.php

class ProcessQueueOne extends ProcessQueueBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff now

    parent::doSomethingCommon();
  }    
}


In src/Plugin/QueueWorker/ProcessQueueTwo.php

class ProcessQueueTwo extends ProcessQueueBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff now

    parent::doSomethingCommon();
  }    
}


OR should I create separate classes that all extend QueueWorkerBase and then just create services for the common functionality.

Something like this:

In DoSomethingService.php:

class DoSomethingService {

  public function doSomethingCommon(){
    // Do something
  }

}


In src/Plugin/QueueWorker/ProcessQueueOne.php

class ProcessQueueOne extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff

    $do_something = \Drupal::service('mymodule.doSomething');
    $do_something-&gt;doSomethingCommon();
  }    
}


In src/Plugin/QueueWorker/ProcessQueueTwo.php

class ProcessQueueTwo extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff

    $do_something = \Drupal::service('mymodule.doSomething');
    $do_something -&gt;doSomethingCommon();
  }    
}
I would suggest an abstract base class, but instead of creating another function ::doSomethingCommon, partially implement ProcessQueueBase::processItem and call parent::processItem from the subclasses.