On Sat, Mar 13, 2010 at 3:55 PM, Jerome David Sallinger
<imran.nazir / yahoo.co.uk> wrote:
> Thank you for all the ideas peeps. Much appreciated, I was hoping that
> there was some way to avoid iterators/loops such that a 'Ball' object
> would be aware of its locatation in, for simplicities sake, '2D' space
> and weather it shares it with anything else. If not then that cool but
> maybe there is some undiscovered territory concept wise for me to
> explore.

I'd suggest looking at the Observer pattern.

Have each Ball continuously register its location (x,y) with a single
Observer object; an attempt to register to an occupied location can
be handled however you want -- throw an exception, send the Ball
a message to reverse direction, vaporize the Ball, etc.

No loops or iterators in sight  :-)

FWIW,
-- 
Hassan Schroeder ------------------------ hassan.schroeder / gmail.com
twitter: @hassan