Re: Design by Contract
| From: | Yasuo Ohgaki | Date: | Mon, 09 Feb 2015 20:27:56 +0000 |
| Subject: | Re: Design by Contract | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82317@lists.php.net to get a copy of this message | ||
Hi all,
On Tue, Feb 10, 2015 at 5:19 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Use of interface:
> - no additional keyword (pros)
> - requires interface for DbC, most classes does not require interface
> (cons)
> - if interface is not used, user has to repeat invariant conditions over
> and over (cons)
> - requires to define method that should not exist in production (cons)
>
> New keyword:
> - does not require interface for efficient definition (pros).
> - new keyword (cons)
>
> It seems we are better to choose proper keyword for 'invariant'.
> 'invariant' is not common, so 'invariant'
> may be good enough choice. Does anyone use 'invariant' as
> function/method/class/constant names?
> If there is better name, suggestion is appreciated.
>
It might be be better to use special method. No keyword, use only reserved
method name __func().
I'll write what I think that are better for PHP in the RFC.
We may discuss anything here to complete the RFC.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net