The Symmetric Proxy Pattern | 473
Even though both of the solutions are workable, they may lack the flexibility and
reusability desired in good design patterns. We need to look further.
The Symmetric Proxy Pattern
The Symmetric Proxy pattern is as much a discovery as an invention. Heliotis and
Schreiner found that they could establish instances of two player objects arranged as
peers over the Internet. Each side has both a proxy and a “real” player. Likewise, the
referees on each side have the same information. Whatever move a player makes is
treated the same by each of the referees. The referee object has no idea where a move
comes from—it’s clueless, as Heliotis and Schreiner note. All that the referee has to
do is to call the players when the game is over and let them know the outcome. The
referees are perfectly synchronized because they’re reacting to the same state infor-
mation, without caring whether the information is local or from a proxy; as a result,
when the game-over conditions are met, both inform the players in exactly the same
way, resetting all variables, and preparing for the next game.
Figure 13-3 shows the object diagram of the Symmetric Proxy Pattern:
Keeping in mind that Figure 13-3 is an object diagram and not a class diagram, we
can clearly see that the Symmetric Proxy pattern has each player’s proxy in the oppo-
sition’s camp, so to speak. The referees are treating each side of the Symmetric Proxy
as a complete game. The referee simply takes the moves, evaluates them as being
from one side or the other, and makes game decisions as though only a single host is
in use. In other words, the proxies are treated as the computer playing the live
player, or two live players taking turns on the same keyboard.
Figure 13-3. Symmetric Proxy object diagram
Referee 1
Player 1 Proxy 2
Internet
Referee 2
Proxy 1 Player 2