O'Reilly logo

Struts Kick Start by Kevin Bedell, James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Well-Designed Models

To begin with, the Action should be as insulated as possible from the actual implementation of the model. This can be done by using abstraction. For example, if the model uses JNDI to look up a username and password in an LDAP server, you shouldn’t put JNDI-specific code in the Action.

Instead, the Action should communicate through an interface (or at least a well-defined API) to the model, and the model should do all the work of setting up and making the JNDI call. That means if you want to change the model later to have it use JDBC to talk to Oracle, for example, only the model code would change; the Action could remain untouched.

To illustrate this, take a look at Stock.java (see Listing 9.1), which implements the model ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required