何时何地使用Guice依赖注入?(When and where to use dependency injection with Guice?)

编程入门 行业动态 更新时间:2024-10-27 23:24:52
何时何地使用Guice依赖注入?(When and where to use dependency injection with Guice?)

我最近在大学课程中学习过Guice,并且看过Google I / O视频 。 在视频中,他们声称在每个Google项目中使用它,包括Wave等。我在想 - Guice真的无处不在吗? 它对Java中的程序员来说真的是必须知道必须使用的吗? 我应该经常在工厂使用吗?

谢谢

I've recently studied about Guice in a University course, and have seen the Google I/O video about it. In the video, they claim to use it in every Google project, including Wave, etc. I was wondering - is Guice really that ubiquitous? Is it really a must-know-must-use for programmers in Java? Should I always use it over a factory?

Thanks

最满意答案

Guice真的无处不在吗? 它对Java中的程序员来说真的是必须知道必须使用的吗?

谷歌之外 - 不,不是真的。 我不是说它不是一个好产品,它现在似乎没有被广泛使用。 还有其他更成熟的框架提供依赖注入,如Spring或EJB。 主要区别在于Guice 只进行依赖注入。

我应该经常在工厂使用吗?

当然不是。 依赖注入是一种有用的模式,但与所有有用的工具一样,使用它有正确和错误的时间。

is Guice really that ubiquitous? Is it really a must-know-must-use for programmers in Java?

Outside of Google - no, not really. I'm not saying it's not a good product, it just doesn't seem very widely used right now. There are other, more established frameworks out there that provide dependency injection, like Spring or EJB. The main difference is that Guice only does dependency injection.

Should I always use it over a factory?

Of course not. Dependency injection is a useful pattern, but as with all useful tools, there's a right and a wrong time to use it.

更多推荐

本文发布于:2023-08-07 22:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466467.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Guice   dependency   injection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!