How about a “go-between” object?

A common solution to the design problems we left you with is to create a new object—a single, “go-between” object for the controller to talk to rather than having the controller deal directly with the remoteness of the remote model.

Problem 1: Hide the complex JNDI lookup

If Rachel’s controller lets a “go-between” object handle the JNDI lookup, the controller code can stay simpler, free from having to know where (and how) to look up the model.

Problem 2: Hide “remote-ness complexity”

If the “go-between” object can handle talking to the stub, Rachels’ controller can be shielded from all the remote issues including remote exceptions.

image with no caption

Get Head First Servlets and JSP, 2nd Edition 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.