Inspector Gadget and Docs: Design-By-Contract, Object Constructors, and Error Stacks in JavaScript
Alex Vincent has a great way to help debugging and pre/post-conditional testing in JS.
I really like the Design-By-Contract methodology.
I've been thinking of this one for a while, using a system of debug asserts to test pre and post-conditions. I remember we used to have a function documenting style in DS309 (PJ's subject of course) that included both pre and post-conditional comments (+ function description). This was for the "user" of the function, to understand what were the requirements of using it.
Then over the years I thought wouldn't it be cool to have this automatically tested, either using main()/test functions in the class, or using Unit tests. Then what about using MACRO based tests via something like PRECONDITION() that would only work in debug code (much like mozilla's NS_PRECONDITION).
No comments:
Post a Comment