3 ms·
With DCI do you ever need to extend/include multiple modules? Would this single-inheritance approach work?
by andyl 14y ago
With DCI do you ever need to extend/include multiple modules? Would this single-inheritance approach work?
- halostatue 14y agoAs long as the interactions you're working with don't implement the same methods, it would be trivially easy: 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.