依赖注入和控制反转

2.1 Dependency Injection and Inversion of Control

Java applications — a loose term that runs the gamut from constrained applets to n-tier server-side enterprise applications — typically consist of objects that collaborate to form the application proper. Thus the objects in an application have dependencies on each other.

Although the Java platform provides a wealth of application development functionality, it lacks the means to organize the basic building blocks into a coherent whole, leaving that task to architects and developers. True, you can use design patterns such as FactoryAbstract FactoryBuilderDecorator, and Service Locator to compose the various classes and object instances that make up an application. However, these patterns are simply that: best practices given a name, with a description of what the pattern does, where to apply it, the problems it addresses, and so forth. Patterns are formalized best practices that you must implement yourself in your application.

The Spring Framework Inversion of Control (IoC) component addresses this concern by providing a formalized means of composing disparate components into a fully working application ready for use. The Spring Framework codifies formalized design patterns as first-class objects that you can integrate into your own application(s). Numerous organizations and institutions use the Spring Framework in this manner to engineer robust, maintainable applications.

Java应用程序 - 是一个松松的概念。从Applet小程序到n层的服务器端企业程序,通常由互相写作的对象构成来是程序合适运转。因此,在一个应用程序中的对象有彼此的依赖。

尽管Java平台提供了丰富的应用程序开发功能,但它缺少把基本的建造块组成一个有机整体的手段,而是把这个任务留给了架构师和开发人员。当然,你可以使用设计模式构建应用,比如工厂模式、抽象工厂模式、建造者模式、装饰者模式以及服务器定位模式等等来维护各种各样的类和对象实例。然而,这些模式仅仅是:最佳实践给出的名字,给了模式做什么、到那里应用它、解决什么问题的描述。你必须在你的应用中实现这些。

控制的Spring框架反转(IoC)组件针对这一问题提供了组成不同的组件到一个完全工作的应用程序可以使用的形式化手段。 Spring框架编纂正式的设计模式为可以集成到自己的应用程序(S)第一类对象。许多组织和机构使用Spring框架以这种方式来设计健壮的,可维护的应用程序。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值