タグ

ブックマーク / dhh.dk (1)

  • Dependency injection is not a virtue in Ruby (DHH)

    By David Heinemeier Hansson on Jan 6, 2013 In languages less open than Ruby, hard-coded class references can make testing tough. If your Java code has Date date = new Date(); buried in its guts, how do you set it to a known value you can then compare against in your tests? Well, you don't. So what you do instead is pass in the date as part of the parameters to your method. You inject the dependenc

    iakio
    iakio 2013/01/08
    new Date()を避けるためだけにDIじゃないし、DIがdesign for APIのためのものともいえる。じっくり考えたい
  • 1