In this post I summarize four principles of real-time interaction. Shoot.
1. State Driven Control
Event driven control is inductive – it relies on assumptions about the state of the world. Unfortunately, as often as not, these assumptions are incorrect.
State Driven Control is deductive – it relies on evaluating the current state of the world before deciding how an entity should be updated.
2. Conflictual Ownership
By default, game objects tend to be modeled as commons. This, quite naturally, leads to the disaster of commons.
Ownership: an interaction cannot take control of a resource without acquiring this resource.
Conflictual: explicit resource conflicts. By default, fail fast. Whenever necessary, define resolution clauses.
3. The Rule of Return
Never register any callback that may never return. Conversely (and more usefully), do not provide registration methods unless you can warrant that the associate callback will fire. At runtime, validate the callback by asserting return conditions.
4. Pedantic Command
In debug mode, do not allow overly concise control – to the contrary, require control to be somewhat declarative as it allows asserting its integrity. Three examples may illuminate this idea:
- glPush() / glPop() - unsafe
- [foo retain] / [foo release] – unsafe
- startAnimation(“dodge”) / stopAnimation() - unsafe
- glPush(myToken) / glEnd(myToken) - safe
- [foo retain:fromBar] / [foo release:fromBar] - safe
(but avoid back references using hash values)
- startAnimation(“dodge”) / stopAnimation(“dodge”) - safe
I’m not especially in the mood to elaborate on this today; questions, however, are not unwelcome.