note 76577 added to language.oop5.abstract
| From: | eamon at gizzle dot co dot ukEamonStraughn | Date: | Fri, 20 Jul 2007 23:20:19 +0000 |
| Subject: | note 76577 added to language.oop5.abstract | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128783@lists.php.net to get a copy of this message | ||
Sometimes I wonder. PHP needs to be pushed to its limits and below everyone fails to understand what
an interface is and what abstraction is. So let me make it extremely clear as I have many languages
under my belt.
Interfaces are in general WYSIWYG implementations of logic which in PHP are not accessible like in
other languages like Java \ ASP.NET where you don't have to access the class itself...however
in future I hope PHP does give us this functionality. Interfaces in PHP only define public functions
without any basic or core functionality therefore making it lesser a friend to PROs from OOP
&& OOD backgrounds.
Instead Abstraction in PHP is perfered as this allows your objects a core with the ability to define
different levels of access to methods | variables | constants. Although publicly allowing access to
variables (to me) | (to official \ senior programmers) defeats the whole idea of OO. Abstraction
allows the keywords of final which is very important to me as I can have many child objects of
objects and of child objects.
Thus knowing the difference helps with your choosen style but if your really looking to make an
application with Abstraction I would always suggest using an Abstract Class instead of Interfaces as
Interfaces are limited and provides no functionality and is a waste of bytes on your hard drive.
The below is an example of Abstraction used in an automated system.
<?php
Abstract Class events
{
protected $priority;
protected $message;
protected $environment;
protected $syslog;
protected $config;
protected $global;
protected $classes;
protected $super;
public function __construct(array &$config)
{
$this->config = $config;
}
abstract protected function writeToDatabase(Environment &$environment);
abstract protected function writeToSystem(Environment &$environment);
abstract protected function writeToEmail(Environment &$environment);
abstract protected function writeToMobile(Environment &$environment);
abstract public function execute(&$class, $method, $args);
protected function environment(Exception &$object) {
$this->super =& new Environment($object, $this->config);
$this->global = $this->super->env();
$this->global = $this->global['environment'];
return $this->super;
}
public function __destruct()
{
unset($this);
}
}
?>
----
Server IP: 194.145.210.3
Probable Submitter: 80.229.71.222
----
Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php
Edit -- https://master.php.net/note/edit/76577
Del: integrated -- https://master.php.net/note/delete/76577/integrated
Del: useless -- https://master.php.net/note/delete/76577/useless
Del: bad code -- https://master.php.net/note/delete/76577/bad+code
Del: spam -- https://master.php.net/note/delete/76577/spam
Del: non-english -- https://master.php.net/note/delete/76577/non-english
Del: in docs -- https://master.php.net/note/delete/76577/in+docs
Del: other reasons-- https://master.php.net/note/delete/76577
Reject -- https://master.php.net/note/reject/76577
Search -- https://master.php.net/manage/user-notes.php