
Shark shark = new Shark(); Collection<Fish> swarm = new ArrayList(); for ( ... ) swarm.add(new Fish()); ... swarm.mimicryAttack(shark);
Swarm Behavior is a new composition operator that associates behavior with a collection of instances. The lookup of swarm behavior is based on the element type of a collection and is thus orthogonal to the collection hierarchy.
The method mimicryAttack …
Fish class,Collection, butFish instances.Fish class.
NB, useful for both static and dynamic languages.