mardi 23 mai 2017

How far to take the single responsibility principle

Say i have a class like so:

class Config
{
   private $configA;
   private $configB;
   private $configC;
   private $configD;

   public function getConfigA(): string
   {
        return $this->confiA;
   }
   //...
}

In one sense this class has a single responsibility: managing config settings.

But in another sense it has lots of varying reasons to change: a config is renamed, new config added, config removed, return types changing, validation required on a config etc etc

Should there be a class for each config setting which would satisfy single responsibility or is that too far?

Aucun commentaire:

Enregistrer un commentaire