You are here: Re: OT « PHP Programming Language « IT news, forums, messages
Re: OT

Posted by Steve on 04/21/07 13:59

"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:PI-dnRXMkqxCwLTbnZ2dnUVZ_qupnZ2d@comcast.com...
| Vince Morgan wrote:
| > "Steve" <no.one@example.com> wrote in message
| > news:zGbWh.1456$go5.566@newsfe12.lga...
| > You are undoubtedly aware that this has to be the most misunderstood
| > behaviour in all of php. Perhaps in all programing in all languages!!
The
| > number of posts I've read in the last few hours that clearly
misunderstand
| > _set() and __get() is astonishing! And all I've gleened from them was
| > further misunderstanding. Cant blame them realy. You have been trying
to
| > hammer the point home but the nails have just kept bending. I don't
think
| > I've ever been so confused about anything in my life.
| > Thank you!!
| > You have my undying grattitude Steve! :)))
| > Vince
| >
| >
|
| Vince,
|
| It's probably misunderstood because it's pretty much a violation of OO
| principles. OO principles indicate you can set and get values - but
| that you have separate setter and getter functions for these.

i think it's because people was to use it as an oop mechanism so they can
have the getters/setters they're used to having in other languages. i
wouldn't mind having __set/__get be a single entry into calling my own
private getters/setters (which is why i've argued that point)...and i can
think of many factors that would lead the php dev group to just leave it at
that for now. again, the problem is that you'd expect php to guard your
objects and throw errors...instead, they just fire those two events in your
object.

i can even understand that though. one of the features of scripting
languages like php and javascript is that you can throw interfaces on
objects you didn't create. at least php is telling you someone is doing it
so you can handle it.

btw, if __set/__get only worked (as everyone expects) on defined interfaces
then there would still not be any oo violations going on. they would be
gateways from which the programmer would appropriately functionality off to
the right private getters/setters that assist any given interface. (i still
don't see how you're missing that point.)

| Now you can emulate this in other OO languages such as Java, C++ and
| SmallTalk. But it's pretty much frowned upon. Experienced programmers
| in these languages pretty much follow the defacto standard to have
| separate getter and setter functions of each value you want to be able
| to change/retrieve.

and if __set/__get worked only on defined interfaces, 'experienced'
programmers would not be lost on the fact that they still would be making
related getters/setters and would be calling them selectively when
__set/__get were fired.

| Doing it other ways just gets into too much of a hassle.

i don't see the big deal, jerry. there are no more additional or magical
steps in using __set/__get than in programming any other property, any other
language.

| Now PHP has tried to implement something which really is against OO
| principles (so what's new here?).

what? would that be object ENCAPSULATION?!!! php is giving you the ability
to BOTH redefine objects you didn't author AND the ability to PROTECT the
ones that you have, should someone try to redefine it. the behavior is
optional. you should be happy with that.

btw, encapsulation is THE first PRIMARY directive in oop. so the 'what's new
here', i'd imagine, is that you still don't understand the ALTERNATE way
people see __set/__get. otherwise, you'd balk less...i would think.

| I've looked at it - but I really don't find it useful. This style is
| not implemented in other languages for very good reason - it really
| complicates the code, just as these functions do in PHP.

omg!

no, you're right...encapsulation is very low in importance. we should be
pissed that php gives us a means to protect the objects we create <sarcasm
of course>. i'm happy to accidentally misspell an interface name and not get
errors from php or the author, yet spend hours trying to figure out why the
value of the correct property is wrong. you're right, doing away with
__set/__get really does uncomplicate things.

what bowl were they hitt'n when they put that in there?!!!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация