class::contract

statico on 2005-02-02T03:36:04

C. Garrett Goebel has decided to honor my request of maintaining Class::Contract, which I look forward to hacking on to get some of the "Future Work" functionality described in the documentation. I don't have the time right now to begin working on it, but the TODO section is so deep that improving it may warrant an independent study.

In the meantime, my class partner and I are using it for our software development class, and are so far really excited about it. I understand that pre- and post-conditions are a thesis-worthy topic by themselves (heck, we're one handshake away from the guy who did write the thesis), and Class::Contract seems to Do The Right Thing. Also, it does some Spiffy-esque things, such as automatically shifting $self and providing it through the self function instead. In postconditions, you can have access to the copy of the object that existed before the method/accessor was called via the old function and check the return value via value.

My partner and I really appreciate being able to write:

    # optional callback to notify player of the number of followers they have
    method 'notify_follower_count';
        # ensure first argument is a valid amount of followers
        pre { is_int($_[0]) && 0 <= $_[0] && $_[0] <= 7 };


Hopefully, better-educated, computer science-worthy explanations will follow as the class progresses.

Damian++, Garrett++.