Application Layers

The application is layered to limit any dependencies to a single layer if possible. This is a generally accepted practice and one that we always recommend. Figure 15-1 shows the different layers of the sample application together with the Spring- and non-Spring–related configuration files that are associated with each layer.

image from book
Figure 15-1

One thing you will notice once you start working with Spring is that you write considerably less code in your business classes. Most "glue" code is now unnecessary, as configuration is now handled by the framework. You will also be able to use AOP for crosscutting concerns such as transactions and security. This usually amounts to a considerable amount of code that can be eliminated by using Spring-provided AOP solutions.

The downside to this Java code saving is that it all has to be configured, so you end up with some additional XML files. This is, however, a one-time problem as you start developing the application and it is far more than made up for by the time saved on writing repetitive "plumbing" code. It's also important to note that virtually all applications of real-world complexity that we've seen face the need to externalize configuration from Java code in one way or another. Thus the XML configuration in a Spring application is typically a consistent alternative to ad hoc configuration that would otherwise be scattered — perhaps less visible in a single place, but often amounting to more total configuration, and a greater maintenance burden.

You will notice the biggest difference later on when you have to maintain the application. When you go back into your application to make changes, you will have a much easier time understanding and modifying the code. This is because all this extra code cluttering your core business logic code is no longer there. Finding the right location in the code where you need to make changes is much easier. Also, the configuration files give a high-level "road map" of the application, and the highly coherent, loosely coupled classes that IoC and AOP encourage are easier to maintain.

Professional Java Development with the Spring Framework
Professional Java Development with the Spring Framework
ISBN: 0764574833
EAN: 2147483647
Year: 2003
Pages: 188 © 2008-2017.
If you may any questions please contact us: