This paper describes a methodology called "State Oriented Programming" to generate code from state-machine based formal design speci.cation. The methodology is focused on the safety critical systems. In order to achieve highly reliable system development, the following several key techniques are presented: 1) "State-of-interest" based design technique which seamlessly incorporates system/hazard analysis into the design and executable code 2) Automated "transparent" code generation technique that mitigates unexpected behaviors of the code 3) Fully deterministic "backward" execution mechanism of the generated code