Imagine this simple PHP class:
<?php
class MyParent
{
// this is our common method, we don't use this method anywhere in parent class
// but we may or may not use this method in some child classes.
protected function helperMethod()
{
// code
}
}
How is it to have methods like top one in our classes? Is this OOP? I don't have good feeling about this, cause if we don't use these methods in our child classes they will be completely useless and they can confuse people. please tell me your idea.
Another example:
abstract class Package
{
// We will never use this method in this class
protected function getAConfigParam()
{
ConfigHolder->getParam('myconfig');
}
public function register()
{
[...]
this->registerPackage();
[...]
}
abstract public function registerPackage();
}
class PackageForCli extends Package
{
public function registerPackage()
{
// We will use getAConfigParam method here.
}
}
class PackageForWeb extends Package
{
public function registerPackage()
{
// We will use getAConfigParam method here.
}
}
In the top example we have also access to the ConfigHolder in child classes, but which one should we use? getAConfigParam method or ConfigHolder?