RAII type things are part of it. The rest is simply making sure all the constraints are met. The fewer operational constraints, the better.<p>For text I&#x2F;O parsing, just be semi formal about it at least. Check your indices, be careful of integer overflow and be judicious in the use of floating point. Use block I&#x2F;O instead of the finer-grained things in stdio.h .<p>Have instrumentation built in that you can enable to capture test vectors ( if you have the resources ). Error counters can tell you a lot.<p>the mechanism of choice for managing complexity tends towards state machines and sometimes message passing.<p>That&#x27;s a start.