Re: php 5 classes: public, protected and private
- From: Michael Fesser <netizen@xxxxxx>
- Date: Tue, 28 Nov 2006 01:14:59 +0100
..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.
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.
It
does not add any functionality, it merely creates restrictions which often
get in the way.
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.
Micha
.
- Follow-Ups:
- Re: php 5 classes: public, protected and private
- From: Tony Marston
- Re: php 5 classes: public, protected and private
- References:
- php 5 classes: public, protected and private
- From: jopperdepopper
- Re: php 5 classes: public, protected and private
- From: Jerry Stuckle
- Re: php 5 classes: public, protected and private
- From: jopperdepopper
- Re: php 5 classes: public, protected and private
- From: Jerry Stuckle
- Re: php 5 classes: public, protected and private
- From: Tony Marston
- php 5 classes: public, protected and private
- Prev by Date: Re: xml beginner - hierarchies
- Next by Date: Re: ASP.net 2.0 vs. PHP 5?
- Previous by thread: Re: php 5 classes: public, protected and private
- Next by thread: Re: php 5 classes: public, protected and private
- Index(es):
Relevant Pages
|