Detecting futile interfaces with Moose

Interfaces that have only one implementing class are most often futile. Not always. But often. That is because they are a sign of overgeneralization.

You can detect such interfaces by:

  1. get all interfaces, and then
  2. select those that have only one child.

Take a look at the demo below to see how you can express this in Moose:

Essentially, you express it almost like in natural language:

  1. each isInterface
  2. each subclassHierarchy size = 1
Posted by Tudor Girba at 13 September 2011, 9:40 pm with tags assessment, moose, demo link
|