From: Su Zhang Date: 2011-12-03T05:13:23+09:00 Subject: Re: Inverse Operation of Module#include On 12/2/2011 6:22 AM, Isaac Sanders wrote: > I would suggest an Adapter pattern use here. IF there is something that has > functionality that you want to have shared, and one thing changes, I would > make different subclasses. Example: > > class Team # Base class > > def play > raise "You should use a subclass of Team." > end > > end Hi Issac, What if Team inherits from Group, and both FootballTeam and BaseballTeam depend on some common interface defined in both Team and Group, and I want to alter the implementations for Group at runtime? For example: class Group def cheer # drink_beer or have_barbecue? end end class Team < Group def consult analyze_tactics end end class FootballTeam < Team def cheer super shout end end class BaseballTeam < Team def cheer super roar end end team = FootballTeam.new team.cheer team.consult team = BaseballTeam.new team.cheer team.consult Both types of team share the common Team#consult method, but I cannot be sure if I should do drink_beer or have_barbecue in Group#cheer until runtime, and I want to separate them as different implementations. With module mixin, all the implementations are nicely injected into the inheritance chain. If we derive from Group, the derived class will not be on the same inheritance chain as FootballTeam or BaseballTeam. Su