>From: "Derick Rethans" <[EMAIL PROTECTED]>

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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to