Re: PEAR_Error setters
| From: | Alan Knowles | Date: | Sun, 18 Apr 2004 15:09:36 +0000 |
| Subject: | Re: PEAR_Error setters | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-27921@lists.php.net to get a copy of this message | ||
I'm considering hard
manipulation of the object returned($retval->code = MY_ERROR_CODE), but this is bad OO practise.This is very debatable - Yes - on a large project with considerable unknown components having direct object access can be very dangerous. However, two factors have turned this potentially dangerous situation into recommendations of bad programming practice (particually for PHP). - Java's design/teaching (AFAIK) forcing you to use getter/setters ** look at C# - setters/getters are transparent.. - PHP's being a parse/compile language, where setters/getters introduce considerable overhead in: = more code to parse = function calls are relatively expensive in PHP = Larger API to document.. While I'm not going to say setters/getters are bad in PHP, they should be used with some sceptasim, - do they really add significant benefit? - would allowing access damage behaviour of the object? - how unpredictable does changing the objects properties externally make the behaviour of the object? In alot of simple cases (like pear_error) - you will probably find the conclusion is that introducing setters & getters to a already heavy core component, is a expense not worth taking.. Regards Alan -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com