Name: Anonymous 2012-02-07 14:49
Confused about what the good thing to do would be here.
You have these objects (w/ important methods explained):
So, here's the problem:
Both
In theory, the problem could be solved by having
What would you do?
You have these objects (w/ important methods explained):
element() // output object / drawing surface
calculator() // a physics engine
display(element, calculator)
.onDraw // called via callback by calculator when calculations are done (end of frame)
.onResize // called via callback by calculator when the size of the physical bounding space is changed
ui(element, calculator)
.onUpdate // called via callback by calculator before calculations are done (beginning of frame)
.onResize // same as display'sdisplay needs the element in order to draw to it. ui needs the element in order to calculate human interface movements on it. They both need the calculator in order to pass the event callbacks they need to it. (Callbacks are being used instead of a publish/subscribe model for performance reasons.)So, here's the problem:
Both
display and ui want to know when a resize happens, so they can change their expectations about element. But ui is implicitly dependent on display, because if display makes changes to the size of element after ui adjusts to the resize, then ui's calculations will be completely wrong. In theory, the problem could be solved by having
display's callback go first. But it will be difficult to ensure that this happens, as it will require either very tight coupling, or blind luck. Without tight coupling, it's a just another Crouching Bug, Hidden Exception.What would you do?