我的团队正在研究依赖注入框架,并试图在使用Google-Guice和PicoContainer之间作出决定。
My team is researching dependency injection frameworks and is trying to decide between using Google-Guice and PicoContainer.
我们正在我们的框架中寻找几件事: p>
We are looking for several things in our framework:
两个框架与列出的标准的比较将不胜感激。任何有助于比较两者的个人经验也将是非常有用的。
Comparisons of the two frameworks against the listed criteria would be greatly appreciated. Any personal experiences that help to compare the two would also be extremely helpful.
免责声明:我相信新的依赖注入,所以请问我的noob-ness如果我问与本次讨论无关的问题。
Disclaimer: I'm fairly new to dependency injection so excuse my noob-ness if I asked a question that isn't pertinent to this discussion.
推荐答案您可能希望将Spring包含在您正在考虑的依赖注入框架列表中。以下是您的问题的一些答案:
You may want to include Spring in your list of Dependency Injection frameworks you are considering. Here are some answers to your questions:
Pico - 皮科倾向于劝阻注射器,但除此之外,您的课程不需要了解皮科。只有需要知道的接线(适用于所有DI框架)。
Pico - Pico tends to discourage setter injection but other than that, your classes don't need to know about Pico. It's only the wiring that needs to know (true for all DI frameworks).
Guice - Guice现在支持标准 JSR 330 注释,因此您不再需要代码中的Guice特定注释。 Spring还支持这些标准注释。 Guice们使用的论点是,如果没有Guice注释处理器运行,如果您决定使用不同的框架,这些应该不会有影响。
Guice - Guice now supports the standard JSR 330 annotations, so you do not need Guice specific annotations in your code anymore. Spring also supports these standard annotations. The argument that the Guice guys use is that without a Guice annotation processor running, these shouldn't have an impact if you decide to use a different framework.
Spring - Spring旨在让您避免在代码中提及Spring框架。因为他们确实有很多其他的帮助者/实用程序等等,但是依赖于Spring代码的诱惑是非常强大的。
Spring - Spring aims to allow you to avoid any mention of the Spring framework in your code. Because they do have a lot of other helpers / utilities etc. the temptation is pretty strong to depend on Spring code, though.
Pico - 我不太熟悉Pico的速度特征
Pico - I'm not too familiar with the speed characteristics of Pico
Guice - Guice被设计得很快,参考文献中提到的比较有一些数字。当然,如果速度是主要的考虑因素,应该考虑使用Guice或布线。
Guice - Guice was designed to be fast and the comparison mentioned in the reference has some numbers. Certainly if speed is a primary consideration either using Guice or wiring by hand should be considered
Spring - Spring可能很慢。有一些工作要做的更快,使用JavaConfig库应该加快速度。
Spring - Spring can be slow. There has been work to make it faster and using the JavaConfig library should speed things up.
Pico - 易于配置。皮科可以为您做出一些自动决定。不清楚它如何扩展到非常大的项目。
Pico - Simple to configure. Pico can make some autowire decisions for you. Not clear how it scales to very large projects.
Guice - 只需添加注释并继承自AbstractModule即可绑定到一起。
Guice - Simple to configure, you just add annotations and inherit from AbstractModule to bind things together. Scales well to large projects as configuration is kept to a minimum.
Spring - 相对容易配置,但大多数示例使用Spring XML作为方法用于配置。 Spring XML文件随着时间的推移变得非常大,复杂,需要时间加载。考虑使用Spring和手摇头依赖注射液的混合来克服这一点。
Spring - Relatively easy to configure but most examples use Spring XML as the method for configuration. Spring XML files can become very large and complex over time and take time to load. Consider using a mix of Spring and hand cranked Dependency Injection to overcome this.
Pico - 小
Guice - 中等
春季 - 大
Pico 对Pico有很多经验,但它不是一个广泛使用的框架,所以更难找到资源。
Pico - I haven't had much experience with Pico but it is not a widely used framework so it will be harder finding resources.
Guice - Guice是一个受欢迎的框架及其对速度的关注是受欢迎的,当您有一个大型项目,您正在重新启动很多开发中。我对配置的分布性质感到担忧,即我们的整个应用程序整合在一起是不容易的。在这方面有点像AOP。
Guice - Guice is a popular framework and its focus on speed is welcome when you've got a large project that you're restarting a lot in development. I have a concern about the distributed nature of the configuration i.e. it's not easy to see how our whole application is put together. It's a bit like AOP in this respect.
Spring - Spring通常是我的默认选择。也就是说,XML可能变得麻烦,造成的减速烦恼。我经常最终使用手工制作的依赖注入和弹簧的组合。当您实际需要基于XML的配置时,Spring XML是非常好的。 Spring还为编写其他框架提供了更多的依赖性注入,因为它们在执行此操作时经常使用最佳实践(JMS,ORM,OXM,MVC等),因此可以很有用。
Spring - Spring is usually my default choice. That said, the XML can become cumbersome and the resulting slowdown annoying. I often end up using a combination of hand crafted Dependency Injection and Spring. When you actually need XML based configuration, Spring XML is quite good. Spring also put a lot of effort into making other frameworks more Dependency Injection friendly which can be useful because they often use best practice when doing so (JMS, ORM, OXM, MVC etc.).
- Pico
- Guice
- 春季
- Spring / Guice / Pico比较
- 另一个春季/古代表演比较
- Pico
- Guice
- Spring
- Spring / Guice / Pico comparison
- Another Spring / Guice performance comparison
更多推荐
Google Guice与PicoContainer进行依赖注入
发布评论