Another question which we haven't really talked about when do we use a protected property, and when do we use a private property but add getters? In PHP, the latter is generally slower than allowing direct access to the property, but giving direct access to the property will effectively make the property mutable as we have no way to declare it final or otherwise immutable.
How should we handle these cases? Generally, add setters/getters and if performance is impacted make the property protected but clearly say that we do not guarantee BC for the property, but that users should use the setters/getters instead? Kind regards, Johannes On 11 Mrz., 09:56, dbenjamin <[email protected]> wrote: > +1 for privates. > +1 for good usage of the final keyword as it can be a great tool to preserve > code consistency and to control "what" the developer can override. > A great example is for final constructors which call explicitly a > initialize() method to allow developer to do "extra" stuff. > > +1 because it's a pain in the ass when you start a huge project with a > version of a framework and when at some point you want to update your > vendors with the last releases to benefit of all the new stuff and bugfix > and improvements and all. How many of us just said one day : "Hum it's > working well as it is, why touching anything ? Just let it on this 2 years > ago release, as long as it works :)" > > "Design by contract" ! That's the Symfony 2 approach here, and that's what > the end-user should do ! The DIC is a great tool. That's the best approach > for the developer on so many points and particulary to have total control of > its code, instead of overriding all he sees. (Take Magento for instance, > it's a nightmare). > > I just want to be able to update my vendors at any time, and don't want to > be stressed about it. I just want to read the change log and say "Yeah cool > stuff. Hum, nice the bug is finally fixed !", and then play around with > my Care Bears friends :-) > > Cya > > -- > Benjamin Dulau - anonymation CEO > anonymation.com | code.anonymation.com > [email protected] -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
