Why should you adopt Spring Framework?

27 / May / 2016 by Ankit Arora 1 comments

Spring is an open source framework for Java platform that provides comprehensive infrastructure support for developing robust Java applications. Spring Framework is essentially a skeleton that offers a solid foundation upon which an application can be built.This skeleton structure guides and helps developers throughout the application development process. Unlike single-tier frameworks such as Struts and Hibernate, Spring aims to consolidate the application in a consistent, productive manner, pulling together the best of all single-tier frameworks.

Bottlenecks in the Traditional Approach to Java EE

Java succeeded primarily because of the standardization of several common services for enterprise applications, which J2EE later called Java EE. This platform was adopted by IT giants like Oracle, IBM, Sun, and SAP. Despite its huge acceptance, many Java EE projects failed as these applications were complex and took a lot of time and effort to build. Few reasons for the shortfall of Java EE are:

  • EJB (Enterprise Java Beans) is complicated and promotes a distributed component model in which the server needs to be on a separate machine from the web server. This increases overheads of remote calls that leads to performance issues.
  • J2EE applications are hard to unit test and have huge amounts of plumbing codes which don’t do anything like JNDI lookup code, Transfer Objects, try/catch blocks to acquire and release JDBC resources.
  • Because of the time needed for deployment, testing the application on the Application Server was a slow process. Dependencies of the written code on the Application Server made running the code outside a difficult task. All this led to software becoming untestable.
  • A single artifact had both design and logic as JSP allowed inclusion of Java code in web pages. The designers and developers had to modify it alike, and it turned out hard to maintain.
  • Loading larger data sets resulted in one database query for each item in the set. For example, loading 10,000 customers meant executing 10,000 database queries, which led to performance disasters. The alternative use of JDBC was also difficult as it was hard to avoid resource leaks and implement error handling correctly. Even if done properly, it still meant writing many lines of code for even the simplest database queries.

Tools based on code generation approach have showcased problems of their own. In comparison, frameworks perform better than tool based code generation as they are more flexible at runtime. Though many organisations have developed their own frameworks, it is always best to use a widely accepted and tested framework.

The Spring Effect

Spring can efficiently organize middle tier objects irrespective of whether or not EJB is used. It has transformed EJB to an implementation choice rather than a determinant of applications. It can effectively reduce the rapid growth of Singletons thereby improving testability and object orientation. Spring configuration management services can be used in any architectural layer that facilitates efficient usage. Here are a few ways in which Spring can leverage your business:

  • Modularity

Spring is a layered framework with many modules like AOP, DAO, ORM, JEE, etc. that enable seamless integration with other frameworks such as JSF, Hibernate, Strut, etc. This modularity gives developers the freedom to work with a module of their choice.

 

  • Inversion of Control

Inversion of Control is the core of Spring Framework. It can be best translated and understood through the term, “Don’t call me, I’ll call you”. In a traditional method, an application code is responsible for the flow of control and calls out for class libraries. But in an Inversion of Control framework, the framework invokes the application code and coordinates the workflow.

 

  • Dependency Injection

Dependency Injection is built on Java language constructs and not on framework interfaces. Unlike the traditional method, application classes expose their dependencies using methods that can be directly called by the framework.

 

  • Aspect-Oriented Programming

The AOP model applies services like transaction management to POJOs without any actual need for implementing APIS. It also provides declarative enterprise services as the POJOs can be implemented without affecting the business code.

 

Conclusion

The Spring Framework is a stable and high-quality platform supported by Java EE platforms such as IBM WebSphere, Oracle OC4J, and BEA Weblogic. It supports the adoption of new platforms like Apache Tomcat and OSGi. Because of the flexibility and independence it offers in terms of easy migration, smooth integration, and enhanced application performance, several large companies have deployed Spring for myriad applications including those that are mission-critical.

FOUND THIS USEFUL? SHARE IT

comments (1 “Why should you adopt Spring Framework?”)

  1. Natasha Mary

    Spring framework is interesting topic. Thank you for your clear explanation and details about all important topics in Java Spring

    Reply

Leave a Reply

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