Gunnar Kudrjavets

Paranoia is a virtue

Some interesting quotes about assertions

Every one of us has probably his own passions when it comes to software engineering. Mine are assertions, design by contract, root cause analysis, and static source code analysis. It’s my sad belief that this is as close to Silver Bullet as we’ll get during the next decade.

Based on that I also have to admit that I enjoy pretty much everything John Robbins has ever written. Especially the first part of "Debugging Applications for Microsoft® .NET and Microsoft Windows®". Robbins has this thrilling style of writing where he mixes technical content with his peculiar sense of humor, untypical to most of the technical books I’ve ever read. Here are a couple of quotes from him (quotes without the context are sometimes pretty hard to understand, so if you're looking for more then pick up a book):

To avoid bugs, however, I verify everything. I verify the data that others pass into my code, I verify my code’s internal manipulations, I verify every assumption I make in my code, I verify data my code passes to others, and I verify data coming back from calls my code makes. If there’s something to verify, I verify it. (Page 84)

My stock answer when asked what to assert it to assert everything. (Page 86)

Without assertions, I felt like I was programming naked, and I knew I had to do something about it. (Page 104)

Well, I think that John Robbins is definitely in my list of cool people ;-)

Posted: Jul 11 2004, 08:45 PM by gunnarku | with 2 comment(s)
Filed under:

Comments

Niclas Lindgren said:

I agree that you should verify everything, and keep it by contract, but assert is not the way to do it. At least not if assert is the only verification done.

Well that depends on what assert translates into and what the rest of the code does in a release build, the code path must still work (return failure) in a release build and not popup annoying popups or exit the program.

But it all of course depends on what kind of application we are talking about.
# July 12, 2004 5:03 PM

Gunnar Kudrjavets [MSFT] said:

I totally agree with you. Look also at http://blogs.msdn.com/gunnarku/archive/2004/04/27/121768.aspx and http://blogs.msdn.com/gunnarku/archive/2004/04/28/122738.aspx. These are two posts about having all the assertions turned on in production code and related matters. They contain a number of interesting comments by different people.
# July 12, 2004 5:21 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)