Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Totally agree. If there is any case that your code can't handle, check the input as early as possible and fail there. "The program crashes if we do X" is always better than "Our robot kills people if we do X" Commented Feb 6, 2017 at 14:08
  • 1
    Good suggestion. Good code is code that's proven to never fail but, if it does inexplicably fail regardless, fails in a well-defined way that can be repaired. Code that can not possibly go wrong but, if it does go wrong turns out to be impossible to get at or repair, is not so great... Commented Feb 6, 2017 at 17:41
  • This, I was going to post the exact same thing. The reviewer is pointing out a possible failure, how to handle it is a different question. Commented Feb 9, 2017 at 15:51
  • 2
    Oh, no, do not do an assert in your code. If the assert is not compiled in, no one will ever see it. If the assert is compiled in then your robot will crash. I've seen more than one case where an assert for 'something that could never happen' in production code triggered and brought down not only that system but everything that depended on it. Commented Feb 13, 2017 at 10:28
  • @TomTanner "with a good failure handling, that should already be in place". I am assuming that the code is already able to handle failing assertions here. Which might not be much of a stretch, since safe failure strategies should be part of any physical system. Commented Feb 13, 2017 at 15:27