Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: RFC: Test::Contract - extensible object-oriented runtime check series (DbC)

by Arunbear (Prior)
on Dec 26, 2017 at 13:35 UTC ( [id://1206201]=note: print w/replies, xml ) Need Help??


in reply to RFC: Test::Contract - extensible object-oriented runtime check series

Hi, did you know that there's already a long established notion of a software contract? I.e. Design by contract (or DbC).

With DbC, contracts are actually part of the code, not secondary constructs like unit tests. Contracts and unit tests are different, 'orthogonal' ways of verifying code. Contracts can be enabled/disabled at run time, and you wouldn't test the contract as such, though you could have tests that exercise typical workflows and contract violations would show up as exceptions being raised.

Also contracts in this sense are not meant to validate data, but to verify an object API is working as agreed.

Some modules that support DbC: Class::Contract, MooseX::Contract.

  • Comment on Re: RFC: Test::Contract - extensible object-oriented runtime check series (DbC)

Replies are listed 'Best First'.
Re^2: RFC: Test::Contract - extensible object-oriented runtime check series (DbC)
by Dallaylaen (Chaplain) on Dec 26, 2017 at 16:49 UTC

    Hello Arunbear,

    I probably didn't at the time of the grandparent post, but I did look it up since and abandoned contract in the name for good.

    I don't think what I want is full-fledged DbC though. It's a bit "take it or leave it" - adding it to just some subs looks silly and adding it throughout an (already working) project seems like a bit of overkill and also a big and risky task.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found