You are here: Re: php 5 classes: public, protected and private « PHP Programming Language « IT news, forums, messages
Re: php 5 classes: public, protected and private

Posted by Jerry Stuckle on 11/29/06 13:33

Tony Marston wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:bpudnWTDrLPbNPHYnZ2dnUVZ_tudnZ2d@comcast.com...
>
>>Tony Marston wrote:
>>
>>>"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
>>>news:PeudnRKltLJsufHYnZ2dnUVZ_u2dnZ2d@comcast.com...
>>>
>>>
>>>>Tony Marston wrote:
>>>>
>>>>
>>>>>"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
>>>>>news:j9-dnQB80fVLOvbYnZ2dnUVZ_rOdnZ2d@comcast.com...
>>>>>
>>>>>
>>>>>
>>>>>>Tony Marston wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
>>>>>>>news:Ib6dna_BtYQSifbYnZ2dnUVZ_sSdnZ2d@comcast.com...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>>jopperdepopper wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>>You should read "can be accessed everywhere".
>>>>>>>>>>
>>>>>>>>>>Private members can be accessed by members of the class only.
>>>>>>>>>>Protected members can be accessed by members of the class or a
>>>>>>>>>>derived
>>>>>>>>>>class.
>>>>>>>>>>Public members can be accessed by anyone, including other classes,
>>>>>>>>>>functions and any other code.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>Thanks Jerry. I'm trying to make a bit of sense of the php 5
>>>>>>>>>approach
>>>>>>>>>to classes, and so far having a hard time. I fail to see the 'why'
>>>>>>>>>behind the 'public, protected and private' and stuff like
>>>>>>>>>abstraction,
>>>>>>>>>interfaces and whatnot.
>>>>>>>
>>>>>>>
>>>>>>>Intefaces are not necessary in PHP. Once you have defined a method it
>>>>>>>is a total waste to time to also define an interface. Interfaces are a
>>>>>>>"fix" in those languages as a means of dealing with optional arguments
>>>>>>>and statyic typing. PHP has ifferent ways of dealing with bth of
>>>>>>>these, therefore interfaces serve no useful purpose.
>>>>>>>
>>>>>>
>>>>>>Ah, the great Tony Marston is back to trolling again.
>>>>>>
>>>>>>Wrong. In OO terms, the interface is the way to interact with the
>>>>>>object. It consists of all public members - both methods (functions, in
>>>>>>PHP) and variables. And for derived classes, the base class adds
>>>>>>protected members.
>>>>>>
>>>>>>A PHP interface is something entirely different.
>>>>>
>>>>>
>>>>>I disagree. It is possible to define a function (method) within a class,
>>>>>then to define a separate thing called an "interface". It is possible
>>>>>access
>>>>>the function without using the interface, therefore the interface is not
>>>>>necessary.
>>>>>
>>>>
>>>>Tony,
>>>>
>>>>You really need to learn about OO before spouting off. In OO terms, an
>>>>interface is something entirely different than a PHP interface.
>>>
>>>
>>>How so? All the documentation I have seen describes how an interface
>>>simply describes a method which it imlements. If it is possible to access
>>>a method (a function in PHP) without going though an interface, ten an
>>>interface is not necessary in any language.
>>>
>>
>>You need to understand the difference between an interface as described in
>>OO terms and the PHP interface.
>>
>>The PHP interface defines a set of methods (function) which are required
>>by the classes which implement the interface. Java is similar in that
>>respect. But both are a subset of the total interface.
>
>
> It is possible to access the method directly without an interface, therefore
> an interfae is not necessary.
>

"Possible" != "CORRECT"

>
>>>>PHP is not the only OO language. Some don't even have a term "interface"
>>>>as part of the language. But the still have an interface.
>>>>
>>>>Try some of the books by James Rumbaugh, Grady Booch and/or Ivar
>>>>Jacobson.
>>>>
>>>>
>>>>
>>>>>>>>>Feels like things are being over-complicated
>>>>>>>>>somehow... or it's just my being inexperienced on this...
>>>>>>>>>
>>>>>>>>>Any other reading material on this suggested, someone?
>>>>>>>>>
>>>>>>>>
>>>>>>>>Look for some good books on OO theory and design.
>>>>>>>>
>>>>>>>>Two of the concepts in OO are 'encapsulation' and 'methods'.
>>>>>>>>
>>>>>>>>Encapsulation means the internals of an object are managed only by
>>>>>>>>that object and are not available to anyone else. In PHP these are
>>>>>>>>private members.
>>>>>>>
>>>>>>>
>>>>>>>Wrong. Encapsulation means that the data and the functions which
>>>>>>>operate on that data are contained (encapsulated) within a single
>>>>>>>object. While the methods (functions) thenselves may be visible the
>>>>>>>code behind those methods (i.e. the implementaton behind those
>>>>>>>methods) is not. Encapslation is NOT about hiding information, it is
>>>>>>>about hiding the implementation. It is not necessary to use
>>>>>>>public/private/protected on any methods or properties. It does not add
>>>>>>>any functionality, it merely creates restrictions which often get in
>>>>>>>the way.
>>>>>>>
>>>>>>
>>>>>>Wrong again, Tony. Encapsulation means internal representations of the
>>>>>>object are not visible outside of the class. Just like the base &
>>>>>>mantissa are not visible outside of a floating point number.
>>>>>
>>>>>
>>>>>I disagree. Encapsulation means that both the data and the methods which
>>>>>operate on that data are contained within a single unit or "capsule".
>>>>>The data names and the method names may be visible, it is only the code
>>>>>which lies behind each method name which is invisible. A piece of data
>>>>>may be accessed directly, as in $object->var, or it may be accessed
>>>>>through a getter, as in $object->getVar().
>>>>>
>>>>>If you bothered to read the right books you will see that encapsulation
>>>>>means "implementation hiding" and not "information hiding".
>>>>>
>>>>
>>>>Again, read the experts before spouting off. You have repeatedly shown
>>>>how little you understand about OO programming techniques.
>>>>
>>>>And yes, encapsulation is "implementation hiding". And the variables are
>>>>part of the IMPLEMENTATION.
>>>
>>>
>>>I disagree. Inplementation is code, information is data. If you don't
>>>believe me then read "Encapsulation is not information hiding" at
>>>http://www.javaworld.com/javaworld/jw-05-2001/jw-0518-encapsulation.html
>>>and also "Abstraction, Encapsulation, and Information Hiding" at
>>>http://www.itmweb.com/essay550.htm
>>>
>>
>>OK, so you quote a couple of blogs by people who have their own opinions.
>>
>>Read books by the authors I mentioned. They are the experts on OO, not
>>just anyone who can post a blog or essay on the web.
>
>
> Oh, I see. Only those people who agree with you can be called experts, while
> everyone else is a charlatan. Even Martin Fowler says that "Encapsulation
> Wasn't Meant To Mean Data Hiding" at
> http://homepage.mac.com/keithray/blog/2006/02/22/, so are you saying that
> Martin Fowler is not an expert?
>

First of all, this is not Martin Fowler's text. It is Keith Ray's
interpretation of what Martin fowler said.

And Booch, Rumbaugh and Jacobson are generally considered to be THE
experts on the OO world.

>
>
>>>>>>>>Methods are implemented as functions in PHP. They operate on the
>>>>>>>>object.
>>>>>>>
>>>>>>>
>>>>>>>That's one thing you got right.
>>>>>>>
>>>>>>
>>>>>>More than you got right. Go crawl back into your hole and don't come
>>>>>>out again until you know what you're talking about.
>>>>>
>>>>>
>>>>>I do know what I'm talking about..
>>>>>
>>>>
>>>>Then why do you continually disagree with the recognized experts in the
>>>>OO community, like the ones I mentioned above?
>>>
>>>
>>>I disagree with YOU simply because you clam to be a recognised expert
>>>when in fact you are no such thing. I keep finding papers on the internet
>>>which disagree with your explanations, yet you persist in claiming that
>>>you are right and everybody who dares to disagree with you is wrong. Such
>>>arrogance!
>>>
>>
>>No, you disagree with every recognized expert in the field. Read what the
>>authors I mentioned have to say about it. THEY are the recognized experts
>>in the field.
>
>
> There is no such thing as a single view upon which all "experts" agree.
> Wherever you look, either in books or on the internet, you will come across
> examples where different sets of "experts" have different opinions and
> views. Therefore it does not matter which set of "experts" you choose to
> follow as a different set of "experts" will always say that you are wrong.
>

Yes, you can always find so-called "experts" who disagree. But the ones
I've named are generally considered to be the experts in the field by
most experienced OO designers and other knowledgeable people.

>
>>I can create a paper on the internet saying the sun rises in the west.
>>It's quite simple to do. But that doesn't make it a fact.
>
>
> In your opinion it does if an "expert" says so. You have to know when an
> "expert" is spouting wisdom and when he is spouting bulls*t.
>

So you're saying Booch, et. al. are spouting "bullshit" because they
disagree with little Tony? ROFLMAO!

>
>>Now go home and do some reading. You might actually learn something.
>
>
> The only thing I can learn from you is how NOT to do things.
>

To home and do some reading, troll. And have fun with your incompetence.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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