I am reading a book which asserts (pun intended) “You should load your code with Debug.Assert methods wherever you have a condition that will always be true or false.”
I haven’t been using these two debug methods, but it makes some sense. However, I am loathe to have this stuff littered all throughout my production code bases.
Thoughts?
It is fine, since the compiler omits it in release build. It is not bad practice, and you do not need to remove them from source (indeed, you probably shouldn’t). But you must be careful:
is bad – the
SomethingImportantThatMustExecutewill be ignored in release; you must use:Basically, avoid side-effects in calls to conditional methods and partial methods.