“The Ruby way” (mixins and class reopening) vs. dependency injection

前端 未结 5 1197
生来不讨喜
生来不讨喜 2021-02-07 06:01

In studying mixins vs. dependency injection, I often hear the phrase \"the Ruby way.\" Often developers say something along the lines of

Ruby lets you reo

5条回答
  •  走了就别回头了
    2021-02-07 06:30

    Actually when I came from Java world to ruby world the first thing that I was interested in is how do they manage dependencies. At that time I was using Google Guice in all java projects and I was really inspired by its clever design and ease of use. The first thing that I've done in ruby was my very own DI container that had approximately the same set of features as Google Guice - (it is still here on github but it is very outdated).

    But now after 2 years of working with Rails/Ruby I think that DI is not needed here. The good article on DI in ruby is http://weblog.jamisbuck.org/2008/11/9/legos-play-doh-and-programming it is actually an article about why DI is not needed by author of one of the first DI containers for ruby. It is definitely worth reading.

提交回复
热议问题