Re: New RFC draft "static class constructor"
| From: | Johannes Schlüter | Date: | Tue, 14 Apr 2015 12:40:00 +0000 |
| Subject: | Re: New RFC draft "static class constructor" | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-85803@lists.php.net to get a copy of this message | ||
On Tue, 2015-04-14 at 11:49 +0200, Johannes Ott wrote:
> Am 14.04.2015 um 00:16 schrieb Levi Morrison:
> >> - IMO, the method should be called when the class is created, just after every parent
> >> class and implemented interfaces are created.
> >
> > In general I think static class data and static class constructors are
> > a sign of poorly designed code, which means I am against this feature.
>
> Thanks for the flowers as we would say in Germany! I didn't hear I'm
> doing poor code for a long time now :(
If static elements need initialisation they apparently have state. If
they have state they in 95% of the cases shouldn't be static but bound
to an object instance. Yes there might be cases where this is a good
design, but the language should provide the syntax sugar to lead the 95%
to write good code instead of leading them to write bad code which can
be tested harder and where changes might have unexpected side-effects.
So even if you're code is good and your own use-case is good design,
which I won't question, I don't think advertising it to all users by
providing a language feature is good.
johannes
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc