title: Design by contract using assertions or exceptions?
body: <p>When programming by contract a function or method first checks whether its preconditions are fulfilled, before starting to work on its responsibilities, right? The two most prominent ways to do these checks are by <code>assert</code> and by <code>exception</code>. </p>
  
  <ol>
  <li>assert fails only in debug mode. To make sure it is crucial to (unit) test all separate contract preconditions to see whether they actually fail.</li>
  <li>exception fails in debug and release mode. This has the benefit that tested debug behavior is identical to release behavior, but it incurs a runtime performance penalty.</li>
  </ol>
  
  <p>Which one do you think is preferable?</p>
  
  <p>See releated question <a href="https://stackoverflow.com/questions/419406/are-assertions-good">here</a></p>