I just came across this question about initializing local variables. Many of the answers debated simplicity/readability vs. robustness. As a developer of (remotely deployed) embedded systems, I always favor robustness and tend to follow several seemingly conflicting rules:
Handle every error to the best of your ability in a way that allows the device to continue running.
Design the code to fail as soon as possible after a programming or fatal error occurs.
We've all been trained to validate input to prevent the device from breaking as a result of user (or other external) input; always assume data may be invalid and test it accordingly.
What other specific practices do you follow to ensure robustness? Examples are helpful, but I'm also interested in techniques that are universally applicable.
In control theory, robust control is an approach to controller design that explicitly deals with uncertainty. Robust control methods are designed to function properly provided that uncertain parameters or disturbances are found within some (typically compact) set.
One of the most important points to improve the robustness of our software is to test it. Not only do we have to check the runtime- and input-output-behaviour, also side-effects should be discovered. Testing is a determined, systematic attempt to break a program that you think is working [KePi99].
Robustness is defined as the degree to which a system operates correctly in the presence of exceptional inputs or stressful environmental conditions.
I'm a fan of the techniques described in "The Pragmatic Programmer". I also use TDD, rather than DBC as I find it more flexible and productive. For example some of the techniqes described in 'pragprog' include:
They all seem like common sense, but its amazing how quickly teams deviate from these underpinning principles when faced with deadlines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With