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.
Then what is a Role? (Score:1)
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',
Re: (Score:1)
Still an adjective. Think of interfaces as a flawed form of roles.
Re: (Score:2)
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
Re: (Score:1)
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).
Re: (Score:2)
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