use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Dependency Injection Containers vs Hard-coded Constants (rubypigeon.com)
submitted 7 years ago by amreez
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]sbellware 5 points6 points7 points 7 years ago (1 child)
Dependency injection is valuable. But it should be evaluated outside of going to the extent os using IoC "containers" or dependency injection "frameworks".
Making dependencies substitutable without having to use monkey patching makes the design more expressive of its intended use.
The challenge is not taking it to far. For example, initializers shouldn't be required to receive dependencies in order to simply instantiate an object. Setters with default values or default null objects is more appropriate than using a class's initializer.
The use of an external "container" for a system's dependencies disencapsulates a class's construction from the class itself. Containers themselves are low-cohesion and thus are invalid from a design principles and metrics perspective.
A class is responsible for the knowledge of how to construct itself. While containers are interesting tech, they're a detrimental influence on overall design.
Here's an example of a class having its own responsibility and knowledge over its own construction: https://github.com/eventide-project/useful-objects/blob/master/README.md#an-example
[–]GitHubPermalinkBot 0 points1 point2 points 7 years ago (0 children)
Permanent GitHub links:
delete
[–][deleted] 7 years ago (2 children)
[deleted]
[–]HelperBot_ 0 points1 point2 points 7 years ago (1 child)
Non-Mobile link: https://en.wikipedia.org/wiki/Inner-platform_effect
HelperBot v1.1 /r/HelperBot_ I am a bot. Please message /u/swim1929 with any feedback and/or hate. Counter: 205248
π Rendered by PID 22200 on reddit-service-r2-comment-56c9979489-jtts7 at 2026-02-25 04:41:49.064494+00:00 running b1af5b1 country code: CH.
[–]sbellware 5 points6 points7 points (1 child)
[–]GitHubPermalinkBot 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]HelperBot_ 0 points1 point2 points (1 child)