Re: how to mark protected properties?
| From: | Lukas Smith | Date: | Tue, 08 Jun 2004 07:00:32 +0000 |
| Subject: | Re: how to mark protected properties? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30129@lists.php.net to get a copy of this message | ||
<snip>
Well I do agree that 100% encapsulation can greatly help in making refactoring possible while maintaing the API. However as Alan pointed out they can make simple things clumsy. Especially if you want to use proper getter/setter in PHP4 (where you dont have interceptors) you have to add a ton of methods. Adding a generic getter/setter method is obviously a possibility. Then again this can lead to a rather clumsy method that needs to be gone through even for the simple tasks.
For example I doubt that I will ever have to add some funky getter method to get the connection property in MDB2 (note I probably have to clean up my properties a bit more though to comply with PEAR CS, slap my wrist).
When I was talking about efficiency I was not so much going on about how expensive function/method calls are (but they are!) but more about how much encapsulation can complicate the API.
So my conclusion is decide very wisely if you are going to mark a property public. In all other cases put an "_" in front to make it obivous to users how to deal with the property. And I would like to keep this behavoir for PHP5.
regards,
Lukas