Spring & AOP
The wold is going towards the collaboration suite way. People don't want to write all the generic code again & again. All applications are sure to have the common modules like, login, DB & user session management. As a developer, i don't want to write any more of the user session checks & user roles, permissions etc. Its okay if you are a beginner and trying to learn few basic concepts, but after a certain point, the developer should be just developing the business logic for their product/application.
Spring & AOP comes to our rescue. There are many other ways, but in this blog session, i am going to deal with Spring & AOP.
What is Spring
Spring is a framework.
What is a framework?
A framework is a basic conceptual structure used to solve a complex issue. i.e It is a wrapper or Its a way of repackaging a function or set of functions (related or not) to achieve one or more of the following goals
* Simplification of use
* Consistency in interface
* Enhancement of core functionality
* Collecting discrete processes into a logical association (an object)
It is a re-usable design for a software system (or subsystem). A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an API.
In layman's terms, if you take a manufacturing industry, say a factory that builts CAR. All the parts of the car is not built by the company. The company relies upon various other companies for tires, seats, steering wheel, brake, etc. The car manufacturing unit, gets the parts from various other comanies, assembles them and adds the engine to the car [which is the core, from the company's product perspective] and sends it to dealers.
Similarly, my software product/application deals with say tracking a vehicle. For building my software, i ofcourse require DB, user management etc. There are various vendors who specialize in DB management, for example JDO, Hibernate etc and for User management we have the famous LDAP. I would get those third party tools, integrate them to my application [set them up] and then write the core logic for tracking a vehicle. This makes me, as a developer concentrate only on my business code. There are various frameworks in the market, which already integrate few of the required stuff. This further reduces my initial setup time.
Spring is such a framework that provides us basic features to build any application. The common features & functionalities are already implemented. We have to just configure them using a set of XML files and then start writing our core business code.
What is AOP?
AOP - Aspect Oriented Programming, its a style of programming which revolves around separation of concerns, cross-cutting & dependency inversion. In this, we identify all the code written as separate concerng. Any message that we try to print to console will go under logging, any db connection related code goes under DB connection management. When all such common concerns are ripped out of the code, the business class will contain only the business logic, nothing more. And you have ended up in a cleaner code which can be maintained easily for more than 100 years.
Spring uses AOP to address various concerns and has built a clean framework for us to build our application upon.
Features of Spring Framework:
* Transaction Management: Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Spring's transaction support is not tied to J2EE environments and it can be also used in container less environments.
* JDBC Exception Handling: The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy
* Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services with Hibernate, JDO and iBATIS.
* AOP Framework: Spring is best AOP framework
* MVC Framework: Spring comes with MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework..
Spring, makes the user to write lots of XMLs, but i don;t see that as a negative aspect when compared to the time i save.
So, work smart & stop reinventing the wheels for heaven sake.
A small blog like this will not be sufficient to explain in detail about the features built into spring and this blog is not intended to teach spring anyways. It just speaks out loud on the framework.
Spring & AOP comes to our rescue. There are many other ways, but in this blog session, i am going to deal with Spring & AOP.
What is Spring
Spring is a framework.
What is a framework?
A framework is a basic conceptual structure used to solve a complex issue. i.e It is a wrapper or Its a way of repackaging a function or set of functions (related or not) to achieve one or more of the following goals
* Simplification of use
* Consistency in interface
* Enhancement of core functionality
* Collecting discrete processes into a logical association (an object)
It is a re-usable design for a software system (or subsystem). A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an API.
In layman's terms, if you take a manufacturing industry, say a factory that builts CAR. All the parts of the car is not built by the company. The company relies upon various other companies for tires, seats, steering wheel, brake, etc. The car manufacturing unit, gets the parts from various other comanies, assembles them and adds the engine to the car [which is the core, from the company's product perspective] and sends it to dealers.
Similarly, my software product/application deals with say tracking a vehicle. For building my software, i ofcourse require DB, user management etc. There are various vendors who specialize in DB management, for example JDO, Hibernate etc and for User management we have the famous LDAP. I would get those third party tools, integrate them to my application [set them up] and then write the core logic for tracking a vehicle. This makes me, as a developer concentrate only on my business code. There are various frameworks in the market, which already integrate few of the required stuff. This further reduces my initial setup time.
Spring is such a framework that provides us basic features to build any application. The common features & functionalities are already implemented. We have to just configure them using a set of XML files and then start writing our core business code.
What is AOP?
AOP - Aspect Oriented Programming, its a style of programming which revolves around separation of concerns, cross-cutting & dependency inversion. In this, we identify all the code written as separate concerng. Any message that we try to print to console will go under logging, any db connection related code goes under DB connection management. When all such common concerns are ripped out of the code, the business class will contain only the business logic, nothing more. And you have ended up in a cleaner code which can be maintained easily for more than 100 years.
Spring uses AOP to address various concerns and has built a clean framework for us to build our application upon.
Features of Spring Framework:
* Transaction Management: Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Spring's transaction support is not tied to J2EE environments and it can be also used in container less environments.
* JDBC Exception Handling: The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy
* Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services with Hibernate, JDO and iBATIS.
* AOP Framework: Spring is best AOP framework
* MVC Framework: Spring comes with MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework..
Spring, makes the user to write lots of XMLs, but i don;t see that as a negative aspect when compared to the time i save.
So, work smart & stop reinventing the wheels for heaven sake.
A small blog like this will not be sufficient to explain in detail about the features built into spring and this blog is not intended to teach spring anyways. It just speaks out loud on the framework.
Comments