# Is dependency injection really that useful in this situation?

**URL:** <https://discourse.dry-rb.org/t/is-dependency-injection-really-that-useful-in-this-situation/194>\
**Category:** Uncategorized\
**Created:** [January 20, 2017, 1:30pm UTC](https://discourse.dry-rb.org/t/is-dependency-injection-really-that-useful-in-this-situation/194 "2017-01-20T13:30:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmrichards](https://avatars.discourse-cdn.com/v4/letter/c/a9adbd/32.png) [@cmrichards](https://discourse.dry-rb.org/u/cmrichards)\
**Post date:** [January 20, 2017, 1:30pm UTC](https://discourse.dry-rb.org/t/is-dependency-injection-really-that-useful-in-this-situation/194/1 "2017-01-20T13:30:06Z")

</div>

Referring to : [https://github.com/gotar/dry-web-skeleton/blob/master/lib/commands/update\_post.rb](https://github.com/gotar/dry-web-skeleton/blob/master/lib/commands/update_post.rb)

Is there really a significant advantage to doing this :

include Blog::Import[‘validations.post\_validator’]  
result = post\_validator.call(params)

instead of this ?

result = PostValidator.call(params)

I appreciate that it’s decoupled from the concrete class being used, so in some theoretical sense it is a better design, but what real word benefits will this have?

The only real advantage I can think of is that I can change the dependency in configuration without touching this class. That doesn’t seem like much of an advantage to me. A disadvantage is that it’s now not clear what my validator class is, so I can’t jump directly to it using my IDE - so i’ll be slower. If I want to change the validator class then what’s wrong with just changing the class name in the code?

There are many difficult challenges I experience during software development and none of them are related to the problem using DI seems to solve. To me, it just seems like something nice-to-have but doesn’t have any real world impact. Maybe I’m missing something here? You could argue that it’s easier to test, but in this case I think you’d still want to use the PostValidator class during testing.

Thanks

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/solnic/32/779_2.png) [@solnic](https://discourse.dry-rb.org/u/solnic)\
**Post date:** [January 25, 2017, 9:15pm UTC](https://discourse.dry-rb.org/t/is-dependency-injection-really-that-useful-in-this-situation/194/2 "2017-01-25T21:15:15Z")

</div>

Yep, I recommend referring to schema constants directly. DI is an overkill in this case.
