News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Stuart Herbert's Blog:
Introducing ContractLib (Programming Contracts)
January 13, 2012 @ 14:11:52

In this recent post to his blog Stuart Herbert introduces a system he's created to handle "contracts" in PHP development - ContractLib.

Programming contracts are tests around functions and methods, and they are normally used: to catch any 'bad' data that has been passed into the function or method from the caller, and to catch any 'bad' data generated by the function or method before it can be returned to the caller. These are pre-condition and post-condition tests, and they are tests that either pass or fail.

He points out that by having contracts you not only increase the robustness of your code but you also save time not trying to hunt down data-related issues. Using pre-conditions, you can can check data to ensure things like correct formatting, data that's out of range and data that might be missing. His ContractLib comes with a set of tests that provide good examples of how to use the functionality. Installation instructions are included.

0 comments voice your opinion now!
programming contract contractlib test data bad


blog comments powered by Disqus

Similar Posts

Nessa's Blog: Which Programming Language is For You?

Nick Halstead's Blog: Programming Tips #9 "debug_backtrace"

Travis Swicegood's Blog: PHPT_Ensure v0.1alpha and PHPT_Core v0.1.1alpha released

International PHP Magazine: Poll Question: What Is the Best Way to Do QA for PHP?

php|architect Blog: Professional Programming: DTAP - Part 2 : Other moving Pieces


Community Events





Don't see your event here?
Let us know!


interview opinion symfony2 testing refactor unittest developer podcast release laravel introduction language community threedevsandamaybe list install configure series code framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework