473,839 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php 5 classes: public, protected and private

Hi,

finally giving php 5 a go, and going over the new approach to classes.
Can someone clarify the public, private and protected to me?

I quote the php manual: "The visibility of a property or method can be
defined by prefixing the declaration with the keywords: public,
protected or private. Public declared items can be accessed
everywhere."

But should I read "...can be accessed everywhere within a given class."
or "...can be accessed by all other classes." ?

Job

Nov 27 '06
86 4675

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:j9******** *************** *******@comcast .com...
Tony Marston wrote:
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Ib******* *************** ********@comcas t.com...
>>>jopperdepopp er wrote:

>You should read "can be accessed everywhere".
>
>Private members can be accessed by members of the class only.
>Protecte d members can be accessed by members of the class or a derived
>class.
>Public members can be accessed by anyone, including other classes,
>function s 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,
interface s 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.
>>
>>>>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'.

Encapsulatio n 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 "implementa tion hiding" and not "informatio n hiding".
>>
>>>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..

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Nov 28 '06 #11
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:j9******** *************** *******@comcast .com...
>>Tony Marston wrote:
>>>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Ib***** *************** **********@comc ast.com...
jopperdepop per wrote:
>>You should read "can be accessed everywhere".
>>
>>Private members can be accessed by members of the class only.
>>Protect ed members can be accessed by members of the class or a derived
>>class.
>>Public members can be accessed by anyone, including other classes,
>>functio ns 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,
>interfac es 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.

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'.

Encapsulati on 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.
Encapslati on is NOT about hiding information, it is about hiding the
implementati on. 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 "implementa tion hiding" and not "informatio n hiding".
Again, read the experts before spouting off. You have repeatedly shown
how little you understand about OO programming techniques.

And yes, encapsulation is "implementa tion hiding". And the variables
are part of the IMPLEMENTATION.
>
>>>>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?
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 28 '06 #12

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Pe******** *************** *******@comcast .com...
Tony Marston wrote:
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:j9******* *************** ********@comcas t.com...
>>>Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Ib**** *************** ***********@com cast.com...
>jopperdepo pper wrote:
>
>
>>>You should read "can be accessed everywhere".
>>>
>>>Privat e members can be accessed by members of the class only.
>>>Protecte d members can be accessed by members of the class or a
>>>derive d
>>>class.
>>>Public members can be accessed by anyone, including other classes,
>>>function s 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,
>>interface s 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.
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'.
>
>Encapsulat ion 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.
Encapslatio n is NOT about hiding information, it is about hiding the
implementat ion. 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 "implementa tion hiding" and not "informatio n hiding".

Again, read the experts before spouting off. You have repeatedly shown
how little you understand about OO programming techniques.

And yes, encapsulation is "implementa tion 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 "Encapsulat ion is not information hiding" at
http://www.javaworld.com/javaworld/j...psulation.html and
also "Abstractio n, Encapsulation, and Information Hiding" at
http://www.itmweb.com/essay550.htm
>>
>>>>>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!

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Nov 28 '06 #13
Tony Marston wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Pe******** *************** *******@comcast .com...
>>Tony Marston wrote:
>>>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:j9***** *************** **********@comc ast.com...
Tony Marston wrote:
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
>news:Ib*** *************** ************@co mcast.com...
>
>
>
>>jopperdep opper wrote:
>>
>>
>>
>>>>You should read "can be accessed everywhere".
>>>>
>>>>Priva te members can be accessed by members of the class only.
>>>>Protect ed members can be accessed by members of the class or a
>>>>deriv ed
>>>>class .
>>>>Publi c members can be accessed by anyone, including other classes,
>>>>functio ns 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,
>>>interfac es and whatnot.
>
>
>Inteface s 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,
>therefor e 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.
>
>>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'.
>>
>>Encapsula tion 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.
>Encapslati on is NOT about hiding information, it is about hiding the
>implementa tion. 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 "implementa tion hiding" and not "informatio n hiding".

Again, read the experts before spouting off. You have repeatedly shown
how little you understand about OO programming techniques.

And yes, encapsulation is "implementa tion 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 "Encapsulat ion is not information hiding" at
http://www.javaworld.com/javaworld/j...psulation.html and
also "Abstractio n, 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.
>
>>>>>>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.

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.

Now go home and do some reading. You might actually learn something.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 28 '06 #14
..oO(Tony Marston)
>I disagree. it is *not* necessary for the simple reason that the code will
perform exactly the same function whether methods and properties are marked
as public/private/protected or not.
Then why do we use OOP and high-level languages like PHP at all? Pure
hand-written assembler code will perform exactly the same function.
>It prevents developers from doing things that shouldn't be done, for
example calling an internal method out of context. I don't want all my
methods being publicly available, simply in order to avoid errors and
unpredictabl e results.

That is a matter for programmer discipline, it is not a matter of additional
functionalit y. The code will do exactly the same with or without it.
The code written in a language like Delphi for example will also do
exactly the same with all type checks, range checks, overflow checks
etc. turned off. But does it make sense to do that and just rely on
"programmer discipline"? No, it doesn't, because it will lead to
erroneous code on the long run.

Compilers are able to automatically check a lot of things and warn the
developer if he made a mistake. Such checks and restrictions don't add
any functionality, but are necessary in order to write reliable code.

The same goes for visibility declarations. I don't rely on discipline or
a comment like "please don't call this method". If a method is not meant
to be called directly then it's declared as such - problem solved.

Micha
Nov 28 '06 #15
Michael Fesser wrote:
.oO(Tony Marston)

>>I disagree. it is *not* necessary for the simple reason that the code will
perform exactly the same function whether methods and properties are marked
as public/private/protected or not.


Then why do we use OOP and high-level languages like PHP at all? Pure
hand-written assembler code will perform exactly the same function.

>>>It prevents developers from doing things that shouldn't be done, for
example calling an internal method out of context. I don't want all my
methods being publicly available, simply in order to avoid errors and
unpredictabl e results.

That is a matter for programmer discipline, it is not a matter of additional
functionality . The code will do exactly the same with or without it.


The code written in a language like Delphi for example will also do
exactly the same with all type checks, range checks, overflow checks
etc. turned off. But does it make sense to do that and just rely on
"programmer discipline"? No, it doesn't, because it will lead to
erroneous code on the long run.

Compilers are able to automatically check a lot of things and warn the
developer if he made a mistake. Such checks and restrictions don't add
any functionality, but are necessary in order to write reliable code.

The same goes for visibility declarations. I don't rely on discipline or
a comment like "please don't call this method". If a method is not meant
to be called directly then it's declared as such - problem solved.

Micha
Micha,

Tony and I have been into this before. He breaks into conversations
trying to spout his version of OO, with a few blogs from people no one
every heard of to back him up.

It's not worth getting into the argument. He's just a troll with
delusions of competency.

He'd never survive in a corporate programming shop.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Nov 29 '06 #16

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:bp******** *************** *******@comcast .com...
Tony Marston wrote:
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Pe******* *************** ********@comcas t.com...
>>>Tony Marston wrote:

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:j9**** *************** ***********@com cast.com...
>Tony Marston wrote:
>
>
>>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
>>news:Ib** *************** *************@c omcast.com...
>>
>>
>>
>>>jopperde popper wrote:
>>>
>>>
>>>
>>>>>You should read "can be accessed everywhere".
>>>>>
>>>>>Privat e members can be accessed by members of the class only.
>>>>>Protec ted members can be accessed by members of the class or a
>>>>>derive d
>>>>>clas s.
>>>>>Publ ic members can be accessed by anyone, including other classes,
>>>>>functi ons and any other code.
>>>>
>>>>
>>>>
>>>>Thank s Jerry. I'm trying to make a bit of sense of the php 5
>>>>approac h
>>>>to classes, and so far having a hard time. I fail to see the 'why'
>>>>behin d the 'public, protected and private' and stuff like
>>>>abstrac tion,
>>>>interfa ces and whatnot.
>>
>>
>>Intefac es 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
>protecte d 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.
>>
>>>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'.
>>>
>>>Encapsul ation means the internals of an object are managed only by
>>>that object and are not available to anyone else. In PHP these are
>>>privat e 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 "implementa tion hiding" and not "informatio n hiding".
Again, read the experts before spouting off. You have repeatedly shown
how little you understand about OO programming techniques.

And yes, encapsulation is "implementa tion 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 "Encapsulat ion is not information hiding" at
http://www.javaworld.com/javaworld/j...psulation.html
and also "Abstractio n, 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 "Encapsulat ion
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?

>>
>>>>>>>Method s 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.
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.
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.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Nov 29 '06 #17

"Michael Fesser" <ne*****@gmx.de wrote in message
news:lo******** *************** *********@4ax.c om...
.oO(Tony Marston)
>>I disagree. it is *not* necessary for the simple reason that the code will
perform exactly the same function whether methods and properties are
marked
as public/private/protected or not.

Then why do we use OOP and high-level languages like PHP at all? Pure
hand-written assembler code will perform exactly the same function.
You can write OO code that uses pubic/private/protected and it will perform
exactly the same function as code which does not use
public/private/protected, therefore the use of public/private/protected does
not add any value. It is therefore optional and not mandatory.
>>It prevents developers from doing things that shouldn't be done, for
example calling an internal method out of context. I don't want all my
methods being publicly available, simply in order to avoid errors and
unpredictab le results.

That is a matter for programmer discipline, it is not a matter of
additional
functionality . The code will do exactly the same with or without it.

The code written in a language like Delphi for example will also do
exactly the same with all type checks, range checks, overflow checks
etc. turned off. But does it make sense to do that and just rely on
"programmer discipline"? No, it doesn't, because it will lead to
erroneous code on the long run.
You are missing the point. If a piece of code does exactly the same thing
whether a feature is turned ON or OFF then that feature is optional.
Compilers are able to automatically check a lot of things and warn the
developer if he made a mistake. Such checks and restrictions don't add
any functionality, but are necessary in order to write reliable code.
I disagree. I do not need a statically typed language to write software. I
can do just as well with a dynamically typed laguage. So can all the
millions of other programmers who use dynamically typed languages.
The same goes for visibility declarations. I don't rely on discipline or
a comment like "please don't call this method". If a method is not meant
to be called directly then it's declared as such - problem solved.

Micha
Whether a method or variable is marked visible or not does not make the
software run any differently, therefore it is optional, not mandatory.
Nov 29 '06 #18

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:Vo******** *************** *******@comcast .com...
Michael Fesser wrote:
>.oO(Tony Marston)

>>>I disagree. it is *not* necessary for the simple reason that the code
will perform exactly the same function whether methods and properties are
marked as public/private/protected or not.


Then why do we use OOP and high-level languages like PHP at all? Pure
hand-written assembler code will perform exactly the same function.

>>>>It prevents developers from doing things that shouldn't be done, for
example calling an internal method out of context. I don't want all my
methods being publicly available, simply in order to avoid errors and
unpredictab le results.

That is a matter for programmer discipline, it is not a matter of
additional functionality. The code will do exactly the same with or
without it.


The code written in a language like Delphi for example will also do
exactly the same with all type checks, range checks, overflow checks
etc. turned off. But does it make sense to do that and just rely on
"programmer discipline"? No, it doesn't, because it will lead to
erroneous code on the long run.

Compilers are able to automatically check a lot of things and warn the
developer if he made a mistake. Such checks and restrictions don't add
any functionality, but are necessary in order to write reliable code.

The same goes for visibility declarations. I don't rely on discipline or
a comment like "please don't call this method". If a method is not meant
to be called directly then it's declared as such - problem solved.

Micha

Micha,

Tony and I have been into this before. He breaks into conversations
trying to spout his version of OO, with a few blogs from people no one
every heard of to back him up.
I see. So in your opinion Martin Fowler is of of these "people no one ever
heard of "? He says, like I do, that "Encapsulat ion Wasn't Meant To Mean
Data Hiding" at http://homepage.mac.com/keithray/blog/2006/02/22/

Are you saying that YOU are more of an expert than Martin Fowler? What
arrogance!
It's not worth getting into the argument. He's just a troll with
delusions of competency.
If everyone who disagrees with you is incompetent then the world is full of
idiots. Your opinion is not the only opinion, and there are plenty of
"experts" who have opposing views.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
Nov 29 '06 #19
..oO(Tony Marston)
>"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:bp******* *************** ********@comcas t.com...
>>
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.
RTFM!

Object Interfaces
http://www.php.net/manual/en/languag...interfaces.php

Micha
Nov 29 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1812
by: verbatime | last post by:
Please explain me how this works - or should work: Got my two classes - bcBasic (baseclass) and the derived cBasic. //--------------------------------------- class bcBasic { int number; virtual long myfunc(void); }
45
3638
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes themselves are an exception to this), and 'bootstrap' your program by instantiating a single application object in main(), would that place any limitations on what you could accomplish with your program? Are there any benefits to doing things that...
3
2068
by: Bryan Parkoff | last post by:
I have C++ Primer Third Edition -- Author Stanley B. Lippman and Josee Lajoie. I have been studying it for couple months however it does not provide a valuable information which it is about "friend to class". I am very disappointed because it is the way how C++ Compiler is designed. I assume that "friend to class" is not the good option. If CMain class is initialized before CA class, CB class, and CC class are initialized inside CMain...
14
3811
by: Pratts | last post by:
I am a new one who have joined u plz try to help me bcoz i could not find ny sutiable answer foer this Question Qus>>why do we need classes when structures provide similar functionality??
6
3369
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to create instance of abstract class ColorSpace". I never try to create a class ColorSpace and don't really want to create a regular class with virtual methods. Does anyone know why I am having this problem? The code seems to run fine and I can actually...
11
3855
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of ways to do this through prototyping and other techniques, but these behaviors need to be static and...
5
2011
by: Chris Szabo | last post by:
Good afternoon everyone. I'm running into a problem deserializing a stream using the XmlSerializer. A stored procedure returns the following from SQL Server: <Student StudentId="1" Status="1" Gpa="3.50"> <Person Id="1" FirstName="FirstName0" LastName="LastName0" MiddleInitial="W"/> </Student> In my code, person is the base class and student extends it. When I
2
2376
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is when a nested class inherits from it’s parent class you get this infinite class chain in intellisense when consuming the class. To get around this I created two child classes Reader and Writer which require a base Person object. When consuming...
47
4051
by: Larry Smith | last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever support multiple inheritance. In C++ for instance I noticed that the compiler flags an error if you use the "ref" keyword on a class with multiple base classes. This supports the above quote. However, under the "CodeClass2.Bases" property (part...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10906
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10585
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10647
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10292
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7017
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.