Hi All,
Do you know why software should have only one exit from any function regarding to IEC 61508? Because it takes long way/code to get out from very 'deep code' to the end of the function and it is just easier to exit/return there.
Sugestions?
Hi All,
Do you know why software should have only one exit from any function regarding to IEC 61508? Because it takes long way/code to get out from very 'deep code' to the end of the function and it is just easier to exit/return there.
Sugestions?
The general principle of "one return only" is to be able to ensure that all paths exit, and that the return value can be determined at all times (it is possible in C for example to write a function that returns in several places, but that also "falls out at the end").
If you have extremely complex functions with many levels of nesting, the suggestion would be to simplify the complex function by refactoring the function into several smaller functions, and this would simplify the logic in the complex function (because some of the complexity is now in a different function - the overall complexity is of course essentially the same)
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.