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

use Perl Log In

Log In

[ Create a new account ]

jdavidb (1361)

jdavidb
  (email not shown publicly)
http://voiceofjohn.blogspot.com/

J. David Blackstone has a Bachelor of Science in Computer Science and Engineering and nine years of experience at a wireless telecommunications company, where he learned Perl and never looked back. J. David has an advantage in that he works really hard, he has a passion for writing good software, and he knows many of the world's best Perl programmers.

Journal of jdavidb (1361)

Monday December 15, 2008
06:03 PM

Classes, interfaces, and mixins: an analogy

[ #38092 ]

A class is a noun: Ball.

An interface is an adjective, usually of the form verb-"able": Serializable. Shootable.

A mixin is a gerund: Serializing. Encrypting.

Too bad there's no mixins in the language I have to speak every day. :)

Warning: I've got no clue about this stuff, and I'm a learner expressing an analogy that occurred to him which is likely dead wrong.

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.
  • because they can be either an interface

    role Shootable {
            requires qw(ready aim fire);
    }

    or a Mixin

    role Shooting {
            requires qw(ready);
            method aim (Object target) { ... }
            method fire () { ... }
    }

    or something else entirely …

    role Gun with Shooting {
            has gun => (
                    is => 'Gun',
           

    • Still an adjective. Think of interfaces as a flawed form of roles.

    • I thought a Role was a Mixin. :) But I'd say in this case, it depends on how you use it. Kind of like how an abstract class which implements no methods at all is still an interface, even though it might not be called one.

      --
      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
      • Nah, Mixin inheritance isn't as safe as Role composition. Mixin's can cause diamond patterns in your inheritance, Roles can't (amongst other things).

        • I clearly still have a lot to learn, then. :)

          --
          J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers