note 71063 deleted from language.oop5.overloading by colder
| From: | colder@php.net | Date: | Fri, 10 Nov 2006 12:17:59 +0000 |
| Subject: | note 71063 deleted from language.oop5.overloading by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119582@lists.php.net to get a copy of this message | ||
Note Submitter: ischafat at freenet dot de
Reason: useless
----
I am really no friend of the __get(...) and __set(...) method.
Why?
Because it breaks good programming conventions.
1. It leads to bloated __get() and __set() methods with big switch...case or if...else conditions.
All based on string comparison. Hard to read and hard to maintain.
One task --- One Method
2. They make it difficult for the clients of my class to use it.
For example: I have a read only property. A client is not able to see this fact from the interface
design of my class.
It is far better to declare all your properties private and provide getter and setter methods for
it. If the property is readonly, just skip the setter method. This makes is much more easier for a
client to use my class.