next up previous
Next: The class Up: The final product Previous: The template pattern

The decorator pattern

You'll notice the addition of the Fire subject. The fire subject is essentially a simulation, its main loop is identical to that of the simulation subject. The only difference is, that the fire subject adds an atom with a velocity that puts it on track to collide with the given structure of atoms.

Given that the fire subject is so similar to the simulate subject, it is not necessary to implement a whole new class for it. Rather, we let Fire inherit from Simulate. Then we redefine the methods we need to. The two methods that we redefine are the loadConfiguration method, and the preLoopConfig method. preLoopConfig was added to Simulate to allow classes such as Fire to extend its run routine without completely redefining it.

The end result is that Fire only has the code relevant to adding a firing atom, it does not have to worry about simulating it. VPRenderer had to be modified in order to accommodate for the target and arrows, however due to the nature of the design, none of its code was actually modified, it only had the relevant parts added.


next up previous
Next: The class Up: The final product Previous: The template pattern
James Roper 2004-02-12