Successfully reported this slideshow.
Your SlideShare is downloading. ×

Ruby and DCI

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

Ruby and DCI

  1. 1. Ruby and DCI You’re doing it wrong Simon Courtois - @happynoff
  2. 2. DCI ? Data (domain model) Context Interaction (roles)
  3. 3. Example d::Base < A ctiveRecor class User e}") def tweet _name My nam e is #{nam .se nd_tweet(" TwitterLib end end user = User.find(42) user.tweet_name
  4. 4. Example cor d::Base < ActiveRe class User end module TwitterUser def tweet_name TwitterLib.send_tweet("M y name is #{name}") end end user = User.find(42) user.extend(TwitterUser) user.tweet_name
  5. 5. Performance ? http://tonyarcieri.com/dci-in-ruby-is-completely-broken Tony Arcieri @bascule
  6. 6. Performance ? Benchmark.ips do |bm| bm.report("without dci") { ExampleClass.new.foo } bm.report("with dci") do obj = ExampleClass.new obj.extend(ExampleMixin) obj.foo end end Local - Ok Global - What ?!
  7. 7. Ruby’s cache Ruby VMs cache methods « These caches remain valid so long as we don’t see new types and the class hierarchy doesn’t change. » Tony Arceria
  8. 8. Alternative cor d::Base < ActiveRe class User Evan Light end class TwitterUser < Simp leDelegator def tweet_name TwitterLib.send_tweet("M y name is #{name}") end end user = User.find(42) tw_user = TwitterUser.new(user) tw_user.tweet_name
  9. 9. Questions ? Simon Courtois - @happynoff
  10. 10. Thanks ! Simon Courtois - @happynoff

×