What do you mean by Spring is loosely coupled?



Lets start with an example GSM mobile numbers are compatible with any network.We can change network on any Network Provide (like Airtel,BSNL etc.), sim cards portability compatibility refers to loosely couple. We don’t need any tightly relation or binding with any network.

The same type of compatibility we need to have in our applications.

 Our application should not have any dependency with other layers. Our application should also need not to have any dependency with any layer.


Eg. Like in our application we have view layer, controller  and other layers as below in the picture below..

JEE application Flow
           


Here Business Class A and  DAO Class B is loosely coupled because DAO classes has implemented the interface (R) which is having some rules which need to be followed by JDBC,Hibernate,JPA,iBatis  and any other ORM tool.


By using rule interface in Business class we can inject any ORM tool or use it in business layer.If at run time we have the capability to pass any ORM tools object to business class then our our business class will become loosely coupled with DAO layer.

EJB relating example for more understanding of the concept:

For creating Servlet based application or EJB application we need to implements Servlet Interfaces and Home/Remote interfaces correspondingly. But while creating the same in spring way we can achieve this by creating POJO classes.

Note: By using run time polymorphism and association(HAS-A) relationship they have created Spring.

In these POJO classes, we can provide input using XML files.Spring IOC container has the capability to read XML files and give input to POJO classes


 Read more about IOC in spring in next page...



Next:What are the types of IOC containers in Spring ?


No comments:

Post a Comment

Fixing yum command on linux

You may find yourself having to fix more packages. So you can just remove everything you had installed via  pip and reinstall everythin...