“Programming by contract” is a style of programming where you see the various parts as having a contract to provide certain conditions etc for each other. They will verify those conditions, and refuse to work if not satisfied.
I have used Assertions very successfully for many years in other languages. At the start of a procedure you verify the conditions, and my experience is that this makes debugging much easier.
I found Matt Neuburgs old book, obsolete in many places, but still helpful, and it talks about this on page 250. He subclasses RuntimeException and I can do that, but the code he provides doesn’t seem to work anymore. I subclass RuntimeException and call it “assertion”, and add a method assert
This is the code he writes in the book:
Sub assert (b as boolean, s as string)
text = s
if not b then
raise me
end if
Exception err as assertion
MsgBox err.text
The problem is that xoxo wants something to end the exception. What should this look like today ?