Converting object logic to state-based