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.