Programming & Dev

Software Dev phase 5: Introduction to Spring Framework

Before starting this, first of all, congratulations for making it this far in the series of Software development, From now onwards things are gonna get real, from here we will start producing things that can be seen and used. But before those things yeah there are some more concepts to learn first.

What is spring?


Spring is a dependency injection framework that helps in building JavaEE applications.

What the heck is dependency injection??

For that, we should first understand what is IoC (Inversion of Control) (oh cmon)
Inversion of control is a design pattern that is a strategy or idea to solve a programming methodological problem that removes the dependency problem in the object-oriented design/ object.
To understand this we have illustrated an example below:

class employee{
address add;
public employee(address add2) { 
    add=new address(); 

Now in the above code, the dependency is tightly coupled(dependency between address and employee), if one wants to make changes to the code or try to shift the code to any different environment, it would be very difficult to run it in the last stable state, but if we carry it out in the below manner:–>

class employee{

 address add;
 public void (address add)

Now, in the above case, it is now pretty much loosely coupled and can run efficiently even if we run it into a different environment. Thus, IOC makes the code loosely coupled. In such a case, there is no need to modify the code in order to run it in a different environment.

I know, you have a lot of confusion and blurry understanding of the above concept but don’t worry, in the upcoming articles we will cover a lot of several other examples and codes which will make you understand what dependency injection is about.

In, spring IOCs containers are used to remove the dependency, we provide metadata to IOCs in an XML file. Don’t worry, we will learn about IOC containers in the next article!

Advantages of dependency injection:

  1. It makes the code loosely coupled
  2. Easy to maintain and test

Some advantages of the spring framework:

  1. Due to number of templates such as jdbc , hibernate , jsp which doesn’t require us to write those long codes again
  2. Easy to build JavaEE applications due to so many frameworks
  3. Loosely coupled
  4. easy to test maintain i.e other java frameworks require servers to run whereas it runs on ur own machine
  5. dependency injection

Let’s take the example of JdbcTemplate, you don’t need to write the code for exception handling, creating connections, creating statements, committing transactions, closing connections etc. You need to write the code for executing the query only. Thus, it saves a lot of JDBC code.

If you have any doubts you can ask the questions directly by commenting down below. Also, don’t forget to read our 4th article on the OOPs to understand it completely:

Software Dev Phase 4: Exception Handling

Get the latest tech news and updatesethical hacking tutorials and cybersecurity tips and tricks. Check out MeuSec for more.

Sometimes we include links to online retail stores and/or online campaigns. If you click on one and make a purchase we may receive a small commission.


Leave a Reply

Your email address will not be published. Required fields are marked *