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

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

问题描述

我一直在看一些Ruby依赖注入库。特别是,我查看了 Needle 科普兰。他们已经存在了很长一段时间,但并没有很多用法。



使用这两个图书馆的一些优点和缺点是什么?它确实好像很多图书馆/框架可以很好地利用这两个图书馆,例如 Merb / Datamapper's Hook

解决方案

Jamis Buck,写了Copland和Needle,发布在这里关于针,依赖注入及其在Ruby世界中的用处。



很长,但值得一读,但是如果您希望与您的问题最相关的单一段落,我会建议从最后一个来看:


不需要DI框架。在更多
的刚性环境中,他们有价值。
在像Ruby这样的敏捷环境中,不是
这么多。图案本身可能
仍然适用,但要注意
陷入陷阱,认为您
需要一切特殊工具。
Ruby是Play-Doh,记住!让我们保持
这样的方式。


HTH


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.

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.

解决方案

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 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天全站免登陆