Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
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 reply to Re: Testing by Contract by adrianh
in thread Testing by Contract by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.