In titght coupling between the objects, If dependent object is modified then main object is also need to be modified.
To avoid the tight coupling between the objects spring framework provides Dependence injection.
To avoid the tight coupling between objects then we need to follow pojo and poji model. So if we follow poji and pojo model then it is possible to get the loose coupling between the objects.
Here dependent object is externally injected by calling its Setter, Constructor and interface injection.
In dependence injection, the external entity will provide the dependent object in to main object.
Here Dependence injection three types are there.
1. Setter injection
2. Constructor injection
3. Interface injection.
Advantage of Dependency injection:
To avoid the tight coupling between the objects spring framework provides Dependence injection.
To avoid the tight coupling between objects then we need to follow pojo and poji model. So if we follow poji and pojo model then it is possible to get the loose coupling between the objects.
Here dependent object is externally injected by calling its Setter, Constructor and interface injection.
In dependence injection, the external entity will provide the dependent object in to main object.
Here Dependence injection three types are there.
1. Setter injection
2. Constructor injection
3. Interface injection.
Advantage of Dependency injection:
- Loosely couple architecture.
- Separation of responsibility
- Configuration and code is separate.
- Using configuration, a different implementation can be supplied without changing the dependent code.
- Testing can be performed using mock objects.
No comments:
Post a Comment