Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Not completely into Moose yet, but isn't a role the equivalent of a Java interface?

    In that case, the behaviour you describe has been implemented there as a intended feature: a regular class *implements* the interface.

    Additionally, a role seems to also have the function of an abstract class as well. In Java, overriding concrete methods is, again, a feature you want.

    If you don't want to override a method simply do not include a overloading method in the implementing class.

    It looks like a (sensible) design dec

    • Roles are far more than interfaces. I strongly recommend reading up on them to understand what they do. The protect (usually) against method collision and they provide a default implementation. If you want to use one like an interface, it's simple:

      package MyRole::DoesSomething;

      use Moose::Role;
      requires qw(
          save
          search
      );

      And now your classes (or some other role composed into said classes) must provide save and search methods.

      However, if you have this:

      package MyRole::DoesSomethi

      • And the class using the role also has an 'is_deletable' method, than this potentially very important behavior is silently discarded.

        For a definition of "silently" which means "Code I explicitly wrote in my class itself", perhaps.

        What if you extracted all behavior into roles and composed them into classes? I think that would produce the desired results.