note 71063 added to language.oop5.overloading
| From: | ischafat at freenet dot de | Date: | Fri, 10 Nov 2006 08:32:29 +0000 |
| Subject: | note 71063 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119579@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 66.163.161.117
Probable Submitter: 212.202.148.54 (proxied: unknown)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- https://master.php.net/note/edit/71063
Del: integrated -- https://master.php.net/note/delete/71063/integrated
Del: useless -- https://master.php.net/note/delete/71063/useless
Del: bad code -- https://master.php.net/note/delete/71063/bad+code
Del: spam -- https://master.php.net/note/delete/71063/spam
Del: non-english -- https://master.php.net/note/delete/71063/non-english
Del: in docs -- https://master.php.net/note/delete/71063/in+docs
Del: other reasons-- https://master.php.net/note/delete/71063
Reject -- https://master.php.net/note/reject/71063
Search -- https://master.php.net/manage/user-notes.php