Re: Design by Contract
| From: | Yasuo Ohgaki | Date: | Fri, 13 Feb 2015 23:30:31 +0000 |
| Subject: | Re: Design by Contract | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82649@lists.php.net to get a copy of this message | ||
On Sat, Feb 14, 2015 at 8:19 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> myMethod() {
> require(MyMethod());
> }
>
My hand is not used to new syntax yet. This should be.
myMethod()
require(myMethid())
{
/* */
}
==========
Native DbC support syntax:
class Child {
require($this->age < 18); // Invariant (Class state condition)
public function someMethod($input)
require(somethingAbout($input)) // Precondition
return($ret, somethingReturn($ret)) // Postcondition
{
/* Great! We are certain that caller satisfy precondition, return
appropriate return value and have proper class state! */
}
}
--
Yasuo Ohgaki
yohgaki@ohgaki.net