Your concerns about separate Position roles don’t make sense to me. One is mutable and the other is not. Since position and movement are different things, why not make them different roles in your example? It should be more a...

Nah, some characters and formating has gone wrong. It's sad that MovableType has no way of edit a comment. But another thing what i wanted to say. You mentioned YAGNI. Actually what i say doesn't invalidated YAGNI at all. YAGNI...

No. A movement is an action. It's an abstract thing which doesn't stand on its own, like a character or a space station. It has to be attached to something concrete to exist. The idea that something has to be...

This is not true. I have no other need for movement at this time, so solving a problem I don't have is a very bad practice. That you can re-use it, is more a side-effect. Movement is a single responsibility,...

Actually, for everything you have written i would recommend my own blog that i have written that exactly faces the problem you have. http://blogs.perl.org/users/sid_burn/2014/07/inheritance-is-bad-code-reuse-part-iii.html But it probably makes the sense to read all three parts. The overall problem that you...

Yes, interfaces solve Part of it. The Problem is that interfaces itself don't have Code Reuse because their are just interfaces. In Part II i describe a solution with Roles. That somewhat gives you what interface have plus an implementation....

Why, not created a new blog instead of modifing the old? 1) The "diamond problem" is not the reason against multiple inheritance. And you already can say that this one is solved with the C3 MRO (Method Resolution Order) algorithm....

0. Overview

But you don't change a Role. In this case you need to delete Destroyable first and then apply DestroyableResistances. You also could now say you start with a class without Destroyable or DestroyableResistances and at startup you create just two...

Well, if you discipline yourself you can build a "Role-like" System with multiple inheritance. But it can easily go wrong. Role takes the good idea out of it and makes it nearly impossible to do it wrong. Single Inheritance itself...

I did not say that IO::Seekable exists or was split because someone had the design in mind that i described here. I'm justing saying that the design that i described matches that of IO::Seekable and it is just an example...

Three of the modules you mentioned aren't even usable, are still in the concept phase, or just provide a wrapper around Iterators but not really compareable to something like LINQ in C#. Data::CapabilityBased is just an idea how it could...

Thanks. I never looked in the Mojo::* namespace because i primarly used Catalyst and didn't even expect that something like that would be in Mojo::*. At least it helps to make it better readable. A Lamba Syntax is just an...

map/grep are no iterators at all. They just read the whole list, apply the function to every element and return a new list. Perl itself doesn't have special iterator support. But you still can write something as an iterator, but...

The first thing i wanted to talk about is the map, grep and sort Functions. I think these functions are somewhat special. If someone look at these functions then we can say that these are concepts of a functional programming language.

Comment Threads

First, you should generally be consuming all of your roles in a single with statement:

with qw(Destroyable PositionRW);

By composing those separately as you have (two separate with statement),you’re lose the composition safety of roles and your code is reduced to little more than mixins.

Your concerns about separate Position roles don’t make sense to me. One is mutable and the other is not. Since position and movement are different things, why not make them different roles in your example? And you can define a position inter…

Thanks for your comments, Sid. I saw some interesting things in the second part of your series of posts and I made some comments there about them.

Next, you wrote "Movement" for example should be a behaviour that is re-usable.

This is not true. I have no other need for movement at this time, so solving a problem I don't have is a very bad practice. I'm building an MMORPG and if I try to solve every problem I don't have, I'll never finish. If, and only if, I need to re-use movement behavior, will I solve that problem.

No. A movement is an action. It's an abstract thing which doesn't stand on its own, like a character or a space station. It has to be attached to something concrete to exist.

The idea that a class only should represent abstract things like "Customer", "People", "Car" or other things is not really right. A class represents something specific. In a full object oriented language even something simple like an "int", "float", "string" is already represented as a class. A class should represent one sp…

Term you are searching for is tetrapod (or Tetrapoda), which includes amphibians, reptiles, birds, and mammals :).
See here on Encyclopedia of Life: http://eol.org/pages/4712200/overview .
BTW, Nice series of articles.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community.
Written in Perl and offering the modern features you’ve come to
expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.