If so how, and what value would this rating have in understanding the code?
For example, I would guess that programs using genetic or neutral algorithms would be less predictable than one calculating the sum of pi.
If so how, and what value would this rating have in understanding the code?
For example, I would guess that programs using genetic or neutral algorithms would be less predictable than one calculating the sum of pi.
If you write units tests and pass the tests with colors, you are pretty safe saying it will run in a predictable fashion.
Of course nothing is 100%. Mechanical failures happen, account for those as well. A client machine can have it's power supply explode due to someone spilling coffee in it. Is your server prepared to handle the case of suddenly losing contact with a client?
It's all just a matter of putting safe guard after safe guard after safe guard.
You seem to be asking a variation of the halting problem, so no, there is not a general solution to determine how predictable a program is.
However, you can throw a battery of tests and code reviews at any application and get a heuristic confidence to a program's predictability.
To predict, you have to understand and that is based on your ability relative to the complexity of the application. The rating of complexity can be based on the level of the developer who could understand it: beginner, medium, expert.
Cyclomatic complexity might help you understand how predictable a program is.
As you and others have implied, there seems to be a correlation (if not a causation) between complexity and predictability.
If the system (your program is part of) is not Chaotic it will be pretty predictable.
If the system is chaotic... may be very hard to predict.
Now all you have to do is convert measures of the code like cyclomatic complexity ( which we can measure) into the sort of maths used in complexity theory.
Don't forget to model the OS and runtime as well.