Chapter 8. Spring

In this chapter, we look at an example of an enterprise web application using the Spring framework. While Hibernate provided a single service, the Spring framework provides an efficient way to build and assemble Java applications, with abstractions for many services. Although it supports many services, Spring stays focused and clean with excellent layering and encapsulation. Like EJB, the centerpiece for Spring is a container, and like EJB, the Spring framework provides access to core J2EE services. But that’s about as far as any similarities go. Here’s a metaphor.

I love to kayak and spend a lot of time teaching kayaking skills. One of my specialties is teaching students how to roll an upside-down kayak in whitewater. One day, I was teaching this skill to a muscle-bound hulk and a dainty little 97-lb woman. While I talked through the technique on dry land, Meathead stared into the distance, disinterested. The woman focused well and wanted to practice the foundational techniques over and over. Within a half an hour, she hit her first roll incredibly well while he was just thrashing about, whipping the calm water into fine white foam. He didn’t come close until his third session. In sessions to come, she relied on her technique to improve quickly; he relied on strength, and floundered. When it was time to put the skills into practice, she rolled while he swam. Programmers, take note. It’s usually better to solve problems with simplicity and finesse rather than muscle. ...

Get Better, Faster, Lighter Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.