dee900@anusf.anu.edu.au writes:
.... 1) You wake up each object and call "distance_to(test_point)" for each. Clean but performance hit for waking up.
2) You add x and y as meta_data, rewrite the method distance_to(test_point) as distance_to(x,y). Now you no longer have to wake up each point as the x and y are quickly available in the pluggable brain. It's quicker but less object-oriented. Starts to look a little like old C code - distance_to(x1,y1,x2,y2). Further, it becomes a real mess when your "distance_to" calculation uses many properties in addition to x and y. Make a little test and compare the two approaches.
I would not expect that the performance penalty of method 1 is that great when the objects woken up are relative local. Dieter