Spring framework is one of mostly used framework for Enterprise application development.
Spring is multi-tier open source lightweight application framework. Spring framework provides support to simplify the development of enterprise application in each and every layer. It also support to integrate various other frameworks with it if required. We can implement the complete enterprise application using with spring framework alone.
Dependency injection and Inversion Of Control(IOC):
Spring framework implements the IOC principle to made dependency injection very easy and flexible. We can remove the dependency or tight coupling in between java classes with IOC.
Consider below sample programms.
package com.sample.java.testing;
public class DependencyObjectTest {
}
package com.sample.java.testing;
public class DependentObjectTest {
DependencyObjectTest dependentObjectTest;
DependentObjectTest(){
dependentObjectTest = new DependencyObjectTest();//tight coupling
}
}
Here we have dependency in between DependecyTest and DependentObjectTest objects. these are tightly coupled. Ad if we made changes to resource, we need to do some code changes in our classes as well.
The same can be achieved with IOC as shown below by removing the dependency at compile time.
package com.sample.java.testing;
public class DependentObjectTest {
DependencyObjectTest dependentObjectTest;
DependentObjectTest(DependencyObjectTest dependentObjectTest){
this.dependentObjectTest = dependentObjectTest;
}
}
Here both object are loosely coupled i.e if we no need to make any changes from client side, even if we made any changes to resource.
Dependency Injection(DI):
Dependency Injection is design pattern which implements IOC principle to remove the dependencies from programming. Hence we can manage application easily. Dependency Injection will make our code as loosely coupled which makes it decreases the coupling between class and it's dependency object.
Advantages of Spring Framework: Below are some of advantages we get with Spring Framework
1. Lightweight
2. Inversion of Control which helps loose coupling in between classes.
3. Declarative support
4. Easy and fast Development
Spring is multi-tier open source lightweight application framework. Spring framework provides support to simplify the development of enterprise application in each and every layer. It also support to integrate various other frameworks with it if required. We can implement the complete enterprise application using with spring framework alone.
Dependency injection and Inversion Of Control(IOC):
Spring framework implements the IOC principle to made dependency injection very easy and flexible. We can remove the dependency or tight coupling in between java classes with IOC.
Consider below sample programms.
package com.sample.java.testing;
public class DependencyObjectTest {
}
package com.sample.java.testing;
public class DependentObjectTest {
DependencyObjectTest dependentObjectTest;
DependentObjectTest(){
dependentObjectTest = new DependencyObjectTest();//tight coupling
}
}
Here we have dependency in between DependecyTest and DependentObjectTest objects. these are tightly coupled. Ad if we made changes to resource, we need to do some code changes in our classes as well.
The same can be achieved with IOC as shown below by removing the dependency at compile time.
package com.sample.java.testing;
public class DependentObjectTest {
DependencyObjectTest dependentObjectTest;
DependentObjectTest(DependencyObjectTest dependentObjectTest){
this.dependentObjectTest = dependentObjectTest;
}
}
Here both object are loosely coupled i.e if we no need to make any changes from client side, even if we made any changes to resource.
Dependency Injection(DI):
Dependency Injection is design pattern which implements IOC principle to remove the dependencies from programming. Hence we can manage application easily. Dependency Injection will make our code as loosely coupled which makes it decreases the coupling between class and it's dependency object.
Advantages of Spring Framework: Below are some of advantages we get with Spring Framework
1. Lightweight
2. Inversion of Control which helps loose coupling in between classes.
3. Declarative support
4. Easy and fast Development
No comments:
Post a Comment