I'm trying to decide whether to extend a base interface with additional methods or create several independent interfaces. I have a Task interface that looks like this
interface Task { public function name(); public function run(array $args); } Now I want to add optional description and dependencies methods. Should I create a new DetailedTask interface like this?
interface DetailedTask extends Task { public function description(); public function dependencies(); } This way I could choose to implement either the base Task interface for a basic task class, or the DetailedTask interface if I needed a description and dependencies. Alternately I could create separate interfaces for the extra methods like this.
interface Describable { public function description(); } interface TaskDependent { public function dependencies(); } According to the interface segregation principle, the second is better because it is more flexible. However, I don't ever anticipate using Describable and TaskDependent on anything besides a Task instance. The extra interfaces just seem to add extra complexity. Which technique should I use?