On Thu, Sep 09, 2021 at 12:53:34PM -0400, Ricky Teachey wrote:
I have never heard of DBC and don't have a clue what is stands for. I am not a pro software developer.
DBC stands for "Design By Contract", it is a methodology for developing software. https://en.wikipedia.org/wiki/Design_by_contract The language Eiffel is especially know for DBC, and it has contract testing built into the syntax. https://www.eiffel.com/values/design-by-contract/introduction/ https://www.eiffel.org/doc/solutions/Design_by_Contract_and_Assertions
But I would read these two lines differently, semantically. The if version feels like someone is saying "I am checking for a thing that could happen". The assert version would feel more like "maybe this could happen and I am checking for it because I am scared not to let's just put it here just in case", or said another way "it is imperative that this not happen".
Indeed. Assertions are statements about the expected state of the program, not queries about the current state. https://import-that.dreamwidth.org/676.html -- Steve