Posted under » Methodology on 01 November 2012
This ability to hide from view the inner workings of a class is one of the four most important characteristics of OOP. APIE or :
Its not that we want to hide our own code, but its about reducing dependencies.
Eg. of inheritance.
<¿php
// parent class
class Human {
// public property name
public $name;
public function walk() {
echo $this->name. " is walking...
";
}
public function see() {
echo $this->name. " is seeing...
";
}
}
// child class
class Male extends Human {
// No code in child
}
// child class
class Female extends Human {
// No code in child
}
$male = new Male();
$male->name = "Adam";
$female = new Female();
$female->name = "Eve";
// calling Human class methods
$female->walk();
$male->see();
?>