Do preconditions ALWAYS have to be checked?
Posted
by Pin
on Stack Overflow
See other posts from Stack Overflow
or by Pin
Published on 2010-05-28T11:19:00Z
Indexed on
2010/05/28
11:21 UTC
Read the original article
Hit count: 167
best-practices
These days I'm used to checking every single precondition for every function since I got the habit from an OS programming course back at uni.
On the other hand, at the software engineering course we were taught that a common precondition should only be checked once, so for example, if a function is delegating to another function, the first function should check them but checking them again in the second one is redundant.
I do see the redundancy point, but I certainly feel it's safer to always check them, plus you don't have to keep track of where they were checked previously.
What's the best practice here?
© Stack Overflow or respective owner