Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:14613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99255 invoked by uid 1010); 3 Feb 2005 23:34:29 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 99218 invoked from network); 3 Feb 2005 23:34:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Feb 2005 23:34:29 -0000 X-Host-Fingerprint: 217.13.4.94 bgo1smout1.broadpark.no Solaris 9 Received: from ([217.13.4.94:63942] helo=bgo1smout1.broadpark.no) by pb1.pair.com (ecelerity HEAD (r4105:4106)) with SMTP id 68/60-10528-405B2024 for ; Thu, 03 Feb 2005 18:34:28 -0500 Received: from bgo1sminn1.broadpark.no ([217.13.4.93]) by bgo1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IBC0037KZWRAF90@bgo1smout1.broadpark.no> for internals@lists.php.net; Fri, 04 Feb 2005 00:29:15 +0100 (CET) Received: from pc ([80.203.129.71]) by bgo1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with SMTP id <0IBD00FKX09N9RB0@bgo1sminn1.broadpark.no> for internals@lists.php.net; Fri, 04 Feb 2005 00:36:59 +0100 (CET) Date: Fri, 04 Feb 2005 00:36:57 +0100 To: internals@lists.php.net Message-ID: <051501c50a49$40328430$0300000a@pc> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Mailer: Microsoft Outlook Express 6.00.2800.1437 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 X-MSMail-priority: Normal References: <5.1.0.14.2.20050201111730.0299da70@localhost> <20050203122955.292e6da9@localhost.localdomain> <02da01c50a13$93728720$a900000a@adstate.local> <20050203195911.512edfd9@localhost.localdomain> Subject: Re: [PHP-DEV] [Operators overloading] PHP 5.1 From: tslettebo@broadpark.no (=?iso-8859-1?Q?Terje_Sletteb=F8?=) >From: "Derick Rethans" Oh, hello. I recognise your name as one of the other authors of the book "PHP 5 Power Programming", which I've recently got, and which looks very good. It seems like all the "big guns" are on this list. :) (similar to comp.lang.c++.moderated and comp.std.c++ for C++). > On Thu, 3 Feb 2005, Stanislav Malyshev wrote: > > > PJ>>$b->a++; gives tmp = a; tmp = tmp+1; b->a = tmp; > > PJ>> > > PJ>>In my example (a date object, day being 31), at this I do not know > > PJ>>if one is assigning 32 to the property or if it's the result of > > PJ>>incrementation (or decrementation from 1 to 0). > > > > nor manipulating properties directly :) > > I know you put a :) there, but if you really mean it then you should NOT > be using PHP! Reason: PHP isn't about OO cosyness - it's about solving a > Web problem. Hm, from several postings, I've detected something of a - I don't quite know how to say it in English - resentment against OO on PHP lists and newsgroups. Why is this? Unfamiliarity with it, or what? It typically gets expressed as derogatory expressions like "cosyness" or "cuteness", as a "quick and dirty" attempt to discredit something without any proper argument. Now, whether or not you're accessing properties has nothing in particular with the language you use; it's a design issue. Oh, and it has nothing to do with "cosyness" and everything to do with program robustness, correctness, encapsulation, decoupling of interface from implementation, and other time-honoured software development principles (which are independent of any particular "paradigm", such as OO). Most software development experts aren't "religious" about the issue of accessor functions. If your class is basically just a value container, without any class invariants to maintain, then accessing properties directly may be a reasonable way to do it. In the case of a date object, it's a really bad idea to be able to access the properties directly, because, as it says in the quote above, you may e.g. increment the day beyond the end of the month, setting it to a negative value, etc. In short, it's an error-prone and bad design. Since you think it's a good idea to _have_ public properties for date objects, I'd like to hear your reasons for it. Regards, Terje