On Wed, Apr 9, 2014 at 11:16 PM, Thalhammer, Jeffrey Ryan <
j...@imaginative-software.com> wrote:

> On a related matter, I'm having trouble deciding whether to use abstract
> base classes or roles to define the interfaces.  I do understand why using
> both doesn't make sense.  Bread::Board::Declare works really well with
> class type constraints, so it can automatically figure out what to
> construct for each dependency.  But I'm not sure how it would work (if at
> all) using role types.  So that's pushing me towards abstract base classes.


One tangent here -- absent some compelling reason (which may or may not
exist here), I'd use roles to define interfaces.  Typically, it'd look
something like:

package Thing::Implements::Workspace;
use Moose::Role;
use namespace::autoclean;
requires 'internet_access';
...

etc.

Then your classes -- and other interfaces for that matter -- can simply
consume the interface roles, and you can figure out if some class (or
interface) does an interface by, well, asking its meta-object if it
->does() the interface role.

                                         -Chris

-- 
Chris Weyl
Ex astris scientia

Reply via email to