Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Testing by Contract

by adrianh (Chancellor)
on Jun 30, 2003 at 20:21 UTC ( #270304=note: print w/replies, xml ) Need Help??

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 :-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://270304]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2023-04-01 19:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found