Re: php 5 classes: public, protected and private




"Michael Fesser" <netizen@xxxxxx> wrote in message
news:fdvmm2hngste2mc3v3q50g23ggkra6u2js@xxxxxxxxxx
.oO(Tony Marston)

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.

What's called an interface in PHP is a completely different mechanism
than what you described above.

I disagree. It is possible to define a function (method) within a class,
then to define a separate thng called an "interface". It is possible access
he function without using the interface, therefore the inteface is not
necessary.

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.

Of course it is necessary.

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.

It
does not add any functionality, it merely creates restrictions which often
get in the way.

That is why I said "It does not add any functionality, it merely creates
restrictions"

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

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org


.



Relevant Pages

  • Re: nd6_lookup prints bogus messages with point to point devices
    ... It would be really useful to drop the messages when dealing with point ... I saw this on RELENG_6 sometime after some IPv6 ND changes that were ... I have a giftunnel to my ISP over which I ... interface and I got the same messages you mentioned. ...
    (freebsd-net)
  • Re: What speed is my ethernet interface running
    ... Darren Dunham wrote: ... > we don't set the interface on the ndd properly, ... > dealing with the wrong one. ... and not those of Sun Microsystems. ...
    (comp.unix.solaris)
  • Re: php 5 classes: public, protected and private
    ... PHP has ifferent ways of dealing with bth of these, ... What's called an interface in PHP is a completely different mechanism ... (i.e. the implementaton behind those methods) ... about hiding information, it is about hiding the implementation. ...
    (comp.lang.php)
  • Re: [SLE] SPAM: dhcpd Doesnt Run
    ... > This implies, to my newbie eyes, that the daemon is dealing only with the .1.0 ... > interface (which faces the Internet), and not with the two subnets (which are ...
    (SuSE)
  • Mel will travel the trap
    ... Don't even try to adapt a interface! ... amongst considerable councils, unless they're christian. ... She should nod distinct medals, ... Just locking no matter how a entrance outside the ...
    (sci.crypt)