One of the core concepts in Spring is Inversion Of Control(IOC). It makes use of BeanFactory to manage Java objects from instantiation to destruction. The IOC implements Dependency Injection, thereby
facilitating loose coupling between components(POJOs). When it comes to
large codes, one of the main problems at hand would be the dependencies
between the various classes. Typically high level modules depend on low
level modules for their values/functionalities. Here, whenever a change
is required we have to face the problem of
Spring uses Dependency Injection[DI] as a rescue for this problem. The underlying classes are made abstract and the instantiation, management and class casting of the objects are done by the spring framework’s IOC container.
It is clear from the above pictorical representation, Spring container acts as a bridge between the abstract POJO classes which contains the blue print of the required model and the metadata which provides data for the POJO classes. This way, there is no dependency for classes on one another. Making the programming abstract through dependency injection is the solution for handling the above stated problems which are mainly associated with development, enhancement and maintenance of large codes.
- Rigidity : Changing one part of code might affect other parts of the code
- Fragility : One change might lead to unexpected changes from other parts
- Immobility : Reuse of the code is impossible because the application is so much tangled already.
Spring uses Dependency Injection[DI] as a rescue for this problem. The underlying classes are made abstract and the instantiation, management and class casting of the objects are done by the spring framework’s IOC container.
It is clear from the above pictorical representation, Spring container acts as a bridge between the abstract POJO classes which contains the blue print of the required model and the metadata which provides data for the POJO classes. This way, there is no dependency for classes on one another. Making the programming abstract through dependency injection is the solution for handling the above stated problems which are mainly associated with development, enhancement and maintenance of large codes.