j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Largely a myth. However, I am convinced that "design by contract" and similar methods can be worth the time and effort and could easily be supported by Smalltalk. Has anyone written an Eiffel-like assertion package for Smalltalk classes?
SUnit has largely the same feel: you write checks in parallel with the code. The checks in SUnit are external to the classes, though. Indeed, I've found that not only do I catch a few bugs by using SUnit, but that I end up with cleaner code that I understand better. I think it's just from having to sit and read through the code carefully which does this--making up a good check means you have to really think about how the code works.
For internal checks like you describe, it would be cool if Squeak had a global assert: function:
Object assert: aBlock "check that aBlock is true. Can be disabled via a preference." Preferences doAssertions ifTrue: [ aBlock value ifFalse: [ self error: 'Assertion failed' ] ]
Lex
squeak-dev@lists.squeakfoundation.org