Monday, 7 December 2009

What is Spring and why spring?

Spring is a FRAMEWORK, which facilitates the java development in more flexible and configurable manner.

Why Spring?

In my opinion Spring was developed to reduce the overhead of irritating syntax and rules of EJB. EJB are not only irritating but also SLOW.

So Spring gave you all the functionality of EJB with POJO( plain old java object).
Spring use two things to achieve this : DI and AOP

DI:- Dependency Injection:- What is this?
In most simplest form, suppose you have one Java code in which you need a string called str. you will write following code:

String str = new String();

Basically, here the java file or java bean is taking pain to create a String object.
similarly If we need another Bean object for eg:

MyBean myBean = new MyBean();

Again java Bean is taking pain to create an object.

DI reduce this pain. Whatever we need in a JAVA file is given to it, So in the same java file we will automatically get a myBean object, we dont need to create it.

so the Object on which our java file or bean depend are given to it by Spring container.
OR
the dependency of a JAVA bean is given to it by Spring.
This is called as DEPENDENCY INJECTION.

AOP: Aspect oriented programming:
AOP is basically separation of concern. In simple terms, enhancing the modularity.
For ex- In an office, we try to assign different things to different ppl. Everyone do his/her own work but communicate with each other also.
similarly in a software, AOP helps to assign one work on one component. Separation of work in different component of Software.

That's all..about Spring Basics.

No comments:

Post a Comment