A few working object makes a java application which is seen by the end user as a working application. The application classes must be independent and loosely coupled in case of complex and large Java applications from other Java classes in order to increase reusability chances. Also this approach makes the testing process easy in the unit testing of complex Java application. These classes are integrated together by the dependency injection also known as wiring and it also takes the same amount of
Java classes and components shall not be dependent upon any other java classes. It could be increasing the possibilities of reusage of such classes and they could be tested independently. For decoupling of the java components, there is a need to inject some dependency of various other classesí persent.
Class A is dependent upon Class B in case Class B is used as variable.
When dependency injection is being used, in that case Class B would be given to A through:
In early tips, we discussed the issues around creating and initializing objects and itís variables. Fortunately there is a way of addressing this situation in Spring that is a wonderful design pattern that they have applied to address this aspect. It is a combination of Inversion of Control and Dependency Injection. Many developers mistakenly believe that IOC and DI are the same thing. It is incorrect. IOC deals with inverting the control flow in an application, DI describes
Updated 11-30-2011 at 12:41 PM by Spring Framework