Ruby 依赖注入库 [英] Ruby dependency injection libraries

查看:20
本文介绍了Ruby 依赖注入库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究一些 Ruby 依赖注入库.特别是,我检查了 Needle科普兰.它们已经存在了很长一段时间,但用途并不多.

I've been looking at some Ruby dependency injection libraries. In particularly, I checked out Needle and Copland. They've been around for quite awhile, yet not a lot of usages.

使用这两个库的优缺点是什么?似乎有很多库/框架可以很好地利用这两个库,例如Merb/Datamapper 的钩子.

What are some of the pros and cons of using these two libraries? It sure seems like a lot of libraries / frameworks out there could make good use of these two libraries, e.g. Merb / Datamapper's Hook.

推荐答案

杰米斯·巴克,他写了科普兰和针,在此处发布关于 Needle、依赖注入及其在 Ruby 世界中的用处.

Jamis Buck, who wrote Copland and Needle, posted here about Needle, dependency injection and their usefulness in a Ruby world.

它很长但值得一读,但如果您想要与您的问题最相关的单个段落,我建议从结尾开始:

It's long but worth reading, but in case you want the single paragraph most relevant to your question, I'd suggest this one, from just before the end:

DI 框架是不必要的.在更多严格的环境,它们有价值.在像 Ruby 这样的敏捷环境中,而不是非常.模式本身可能仍然适用,但要注意掉进想你的陷阱一切都需要一个特殊的工具.Ruby 是 Play-Doh,记住!让我们保持就这样.

DI frameworks are unnecessary. In more rigid environments, they have value. In agile environments like Ruby, not so much. The patterns themselves may still be applicable, but beware of falling into the trap of thinking you need a special tool for everything. Ruby is Play-Doh, remember! Let’s keep it that way.

HTH

这篇关于Ruby 依赖注入库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆