官术网_书友最值得收藏!

Injecting dependencies between POJOs

The term dependency injection is not new-it is used by PicoContainer. Dependency injection is a design pattern that promotes loose coupling between the Spring components--that is, between the different collaborating POJOs. So by applying DI to your complex programming, your code will become simpler, easier to understand, and easier to test.

In your application, many objects are working together for a particular functionality as per your requirement. This collaboration between the objects is actually known as dependency injection. Injecting dependency between the working components helps you to unit test every component in your application without tight coupling.

In a working application, what the end user wants is to see the output. To create the output, a few objects in the application work together and are sometimes coupled. So when you are writing these complex application classes, consider the reusability of these classes and make these classes as independent as possible. This is a best practice of coding that will help you in unit testing these classes independently.

主站蜘蛛池模板: 宝鸡市| 丘北县| 荣昌县| 南阳市| 阳朔县| 镇远县| 岳普湖县| 宁国市| 鹿邑县| 井研县| 湛江市| 太康县| 明星| 阜城县| 达孜县| 泗水县| 平潭县| 东丽区| 谢通门县| 昌都县| 望城县| 太原市| 阿坝县| 青田县| 花莲县| 云南省| 正阳县| 石狮市| 青河县| 西林县| 广德县| 波密县| 和顺县| 若尔盖县| 西安市| 罗山县| 南部县| 灵石县| 余姚市| 万宁市| 扬州市|