Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:23315 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13471 invoked by uid 1010); 12 May 2006 18:09:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13456 invoked from network); 12 May 2006 18:09:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 May 2006 18:09:46 -0000 X-PHP-List-Original-Sender: hartmut@php.net X-Host-Fingerprint: 213.136.52.68 mailgate-out2.mysql.com Linux 2.5 (sometimes 2.4) (4) Received: from ([213.136.52.68:44743] helo=mailgate.mysql.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 4F/A3-19568-86FC4644 for ; Fri, 12 May 2006 14:09:45 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate.mysql.com (8.13.4/8.13.4) with ESMTP id k4CI9dSw023437; Fri, 12 May 2006 20:09:39 +0200 Received: from mail.mysql.com ([10.222.1.99]) by localhost (mailgate.mysql.com [10.222.1.98]) (amavisd-new, port 10026) with LMTP id 23271-01; Fri, 12 May 2006 20:09:38 +0200 (CEST) Received: from [10.100.64.53] (10-100-64-53.mysql.internal [10.100.64.53]) (authenticated bits=0) by mail.mysql.com (8.13.3/8.13.3) with ESMTP id k4CI9aE5001638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 May 2006 20:09:37 +0200 Message-ID: <4464CF54.7070802@php.net> Date: Fri, 12 May 2006 20:09:24 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 MIME-Version: 1.0 To: Bastian Grupe CC: Jason Garber , internals@lists.php.net References: <785810036.20060511193536@ionzoft.com> <4464AC64.5050706@gmail.com> <4464C6C9.40307@php.net> <4464C8AE.1050806@gmail.com> In-Reply-To: <4464C8AE.1050806@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailgate.mysql.com Subject: Re: [PHP-DEV] private, protected, readonly, public From: hartmut@php.net (Hartmut Holzgraefe) Bastian Grupe wrote: > Blame my recent use of Java here ;-) > > Well, I think the whole point of ppp is to having to use setters and > getters consistently. i'm going to blame your use of Java for this one, ppp is way older than the setter/getter fashion and as far as i remember the main reason to introduce the setter/getter pattern into java was to have a standard way for Java IDEs to provide access to Java Bean properties in property dialogs in their GUI design tools > I personally wouldn't like to be able to access some members which are > private, and not others. It just *feels* wrong. Think of it as a more fine grained permission system, like unix file attributes. Reading and writing a property value are two different operations and it makes sense to distinguish access rights not only by ownership but also by type of operation. > And I don't know whether or not less typing is really a good argument in > this situation (think unreadable code in shortcut-ish programming > languages). Less typing is not an argument by itself, else we'd all do APL But less typing is less error prone (and no, plese *don't* mention auto-completion here ;), it can be less readable, too, and in this special case it spreads information that should be in one place. Maintainability can become an issue, too. Take a look at typical PHP class implementations: they have all properties on top followed by the member functions. So to find out whether a private property is really provite or whether it has a getter or even a setter, too, i would have to browse the full class code. class example { private $foo; private $bar; [... more properties ...] function __construct() {...} function __destruct() {...} function getFoo() {...} [... more code ...] } So $foo is readonly here and $bar is really private. Or wait, maybe we have just overlooked getBar()? With readonly $foo; on the other hand you have all the information in one place. If you want to go the getter/setter path all the way then we wouldn't need all the ppp stuff anymore alltogether, we would just make everything private and have the getter and setter decide (using instanceof on $this etc.) the access rights. -- Hartmut Holzgraefe, Senior Support Engineer . MySQL AB, www.mysql.com Are you certified? http://www.mysql.com/training/certification