Expert Spring MVC and Web Flow

(Dana P.) #1

Impact on Web Applications


What does all this mean for developing web applications, specifically Spring MVC? Simply put,
you will find that your web applications will become simpler as your business logic is unen-
cumbered by the framework. The web framework’s role in your application will be minimized
to providing translation layer between the HTTP world and your business domain world.
You will write more POJOs, and you will build more successful object hierarchies and
domain models. You will write more tests because it will be easier to isolate pieces of code.
This will increase the quality of your code, and thus the application. Having a strong test suite
will increase the confidence you have in the application functioning correctly. This confidence
will allow you to refactor more, take risks, and react to evolving business requirements faster.


Summary


We reintroduced the Spring Framework and pointed out the three concepts we consider most
important to understand.
Dependency Injection, a type of Inversion of Control, is a mechanism to insert dependen-
cies into application code. The application code is a passive participant, allowing it to remain
free of framework-specific code. By relying on Dependency Injection, the application does not
manage dependency creation or have to actively locate it. The application code becomes very
testable.
The ApplicationContextis Spring’s main object registry and integration point. It is
usually configured via an XML file in which beans and their dependencies are declared. The
ApplicationContexthas many features, but its central role is object creation and Dependency
Injection. In most cases, the ApplicationContextwill be a transparent piece of our applica-
tions, freeing our application logic from Spring-specific integration.
Finally, all of this has been leading up to an emphasis on developing systems with plain
old Java objects. The POJO is a simple concept with powerful repercussions. Using strong
object-oriented development techniques, systems developed with POJOs are testable and
flexible. Most importantly, they allow the developer to concentrate on business logic and the
problem domain instead of how to deal with the framework.
In the next chapter, we will cover principles for web application design, including typical
layers and where the Spring Framework fits in.


CHAPTER 2 ■SPRING FUNDAMENTALS 19
Free download pdf