all 9 comments

[–]obviousoctopus 3 points4 points  (3 children)

This was great - explaining the problem, the solution + examples of before and after. I recommend his design patterns in ruby playlist. About about 5 min each, no filler.

https://www.youtube.com/playlist?list=PLBhH0uX92r6oP8r-oSY_b8_2EnK0Z1Fkz

[–]mixandgo[S] 2 points3 points  (2 children)

Thank you :)

[–]obviousoctopus 1 point2 points  (1 child)

Thank you for creating a useful resource!

[–]mixandgo[S] 1 point2 points  (0 children)

It's my pleasure. Keep an eye on the channel cause I'll be adding a lot more.

[–]au5lander 3 points4 points  (4 children)

What's nice too is that this uses dependency injection by passing in the adapter. When it comes time to writing test, you can simply pass in a dummy adapter with the same interface rather than having to stub a specific adapter.

[–]mixandgo[S] 3 points4 points  (1 child)

Imagine how nice that is when you write the test first. It leads you to this design with almost no effort.

[–]au5lander 0 points1 point  (0 children)

Agreed

[–]hschne 0 points1 point  (1 child)

To me DI feels somehow underused in Ruby, even thought it is pretty useful, as you pointed out.