I know the example code is not very accurate. Acctually, the last
snippet of code make more sense. As you said, a man is not always a
teacher. So, rather than including Teacher into class Man, it's better
to extend a Man object individually as in the following code.
class Person
end
class Teacher
end
degrade_to_module Teacher # or something else, this is imagined by me
.
Class Man < Person
End
a_man = Man.new
a_man.externd(Teacher)
But what I want to said acctually is not relative to these three class.
You can just replace them as class A,B,and C. I think you may recognize
that you have ever encounter this kind of modeling problems.
To some extent, it's relative to role modeling,for example, a man may
play a teacher role. You can always use a delegator to implement a role.
But I think if you can directly mix a degraded class into a object, the
code will be more concise( you don't need write delegate methods),and
the design will be clearer.
Thanks.
uncutstone
--
Posted via http://www.ruby-forum.com/.