Well since the very beginning I've though abstractions are pointless.. I just do not get whether one should use them or not - specially when working as freelancer without the help of anyone else.
Here's a little class I've made to demonstrate it. What I did in these classes could easily be done in regular class. There was no need for an abstract class. Can someone tell me where an abstract class would be useful in a small example please. I want to know when and why to use abstraction, I'm not asking
abstract class Computer{
abstract function turn_on();
abstract function turn_of();
abstract function activate_fan();
}
class Toshiba extends Computer{
function turn_on(){
echo __class__ ." is now on. Green light showing </br>";
$this->activate_fan();
}
function turn_of(){
echo __class__ ." is now of. No light showing </br>";
}
public function activate_fan(){
echo __class__ . " Fan is now running, speed 300rps </br>";
}
}
class Asus extends Computer{
function turn_on(){
echo __class__ ." is now on. Blue light showing </br>";
$this->activate_fan();
}
function turn_of(){
echo __class__ ." is now of. No light showing </br>";
}
public function activate_fan(){
echo __class__ . " fan is now running, speed 80rps </br>";
}
}
$Toshiba = new Toshiba;
$Asus = new Asus;
$Toshiba->turn_on();
$Asus->turn_on();