in reply to Testing by Contract
To a large extent, statically typed languages are all about sprinkling simple tests throughout our code
I'm going to have to take you to task for that oversimplification later :-)
Separating a contract from its class is an interesting idea, and one that's been on my "think about" pile for a couple of years now. For example, it allows you to retrofit contracts onto an existing codebase - something that's non-trivial with Class::Contract.
Some food for thought:
- For any wrapping of functionality around subroutines Hook::Lexwrap is your friend since you can easily scope the change.
- For another perspective, consider the contract as an aspect (in the AOP sense) and apply it to classes with the Aspect module.
- A big problem for DBC in "normal" perl is that there are so many ways to break encapsulation - so you can violate the class invarients in code external to the package. See Fun with Hook::LexWrap and code instrumentation for one possible idea on how to approach this.
- If you've not done it already, go and ready Meyer's Object-oriented Software Construction which goes into the whole DBC deal in depth.
I need to go finish my comments on the evil that is SWEBOK before midnight - maybe some more constructive comments later :-)
In Section
Seekers of Perl Wisdom