Hi Rasmus, On Mon, Apr 10, 2017 at 5:18 PM, Rasmus Schultz <ras...@mindplay.dk> wrote:
> My concern is actually neither performance nor brevity - my concern is, > can you read the code and actually understand what it does, can you write > code without running into surprising side-effects, and so on. Users must not write code that has side effect, just like user must not do it with assert(). DbC has 2 main merits - ensure program correctness by pre/post conditions (and invariant) during development. - better performance and security. With DbC, it's easy to write and maintain _all_ "necessary and sufficient conditions" for _every_ functions/methods that makes sure program correctness. Unit Test can't achieve what DbC can. i.e. It is not feasible to write all "necessary and sufficient conditions" unit tests for every single functions/methods. invariant check is even more difficult. The most important DbC merit is "Ensured program correctness", then security. Performance would be the least important for PHP as you mentioned. P.S. DbC is not a Unit Test replacement. Unless there is Unit Test, pre/post/invariant conditions cannot be checked easily/repeatedly. -- Yasuo Ohgaki yohg...@ohgaki.net