What does extend give you that delegation doesn't?
At the design level - flat hierarchy
At an abstract level - thinking in terms of objects, not classes.
You don't have to. They're built into SimpleDelegator. Syntactically the difference is you'd write:
class MyThing < SimpleDelegator
instead of: module MyThing
And do: MyThing.new(obj)
instead of: obj.extend(myThing)
> At an abstract level - thinking in terms of objects, not classes.It seems to me like you're trying to use a module to solve a problem which can be solved with an object. I don't think that's thinking in objects at all... it's thinking in modules.
class Account; …; end
class Withdrawer < SimpleDelegator; …; end
class Depositor < SimpleDelegator; …; end
acc = Depositor.new(Withdrawer.new(Account.new))
acc.withdraw(40)
acc.deposit(100)
At least that's how I understand it. I'm not convinced that DCI is worth it, but…I don't yet have a need for it in the application that I'm working with.