/TxLibrary /txOraApi -oraBase.class.php -oraNews.class.php -oraPic.class.php /txWebApi -webBase.class.php -webNews.class.php -webPic.class.php /txWapApi -wapBase.class.php : class wapBase extends TxBase {} -wapNews.class.php : class wapNews extends wapBase {} -wapPic.class.php : class wapPic extends wapBase {} -TxBase.class.php : class TxBase {} -TxNews.class.php : class TxNews extends TxBase {} -TxPic.class.php : class TxPic extends TxBase {}
Description
This is my own idea, because there are three interfaces, Wap Ora web. So there are three class library folders created.
But the base class wapBase.class.php webBase.class.php oraBase.class.php the TxBase.class.php method between them. And TxNews.class.php may also use the TxBase.class.php method. So
TxNews.class.php extends TxBase.class.php, but in TxNews.class.php such a class library method, such as the GetList () method, is called oranews::getlist (), But Oranews extends Orabase, and Orabase extends Txbase.
Other words
class TxNews extends TxBase { public function getList(){ return oraNews::getList(); }}class oraNews extends oraBase { public function getList(){ $param = array(); return parent::getData($param); }}class oraBase extends TxBase { public function getData(){ //curl post remote java web api to get Data return array(); } }
Whether such inheritance is problematic, or that its own thinking is wrong.
Reply content:
/TxLibrary /txOraApi -oraBase.class.php -oraNews.class.php -oraPic.class.php /txWebApi -webBase.class.php -webNews.class.php -webPic.class.php /txWapApi -wapBase.class.php : class wapBase extends TxBase {} -wapNews.class.php : class wapNews extends wapBase {} -wapPic.class.php : class wapPic extends wapBase {} -TxBase.class.php : class TxBase {} -TxNews.class.php : class TxNews extends TxBase {} -TxPic.class.php : class TxPic extends TxBase {}
Description
This is my own idea, because there are three interfaces, Wap Ora web. So there are three class library folders created.
But the base class wapBase.class.php webBase.class.php oraBase.class.php the TxBase.class.php method between them. And TxNews.class.php may also use the TxBase.class.php method. So
TxNews.class.php extends TxBase.class.php, but in TxNews.class.php such a class library method, such as the GetList () method, is called oranews::getlist (), But Oranews extends Orabase, and Orabase extends Txbase.
Other words
class TxNews extends TxBase { public function getList(){ return oraNews::getList(); }}class oraNews extends oraBase { public function getList(){ $param = array(); return parent::getData($param); }}class oraBase extends TxBase { public function getData(){ //curl post remote java web api to get Data return array(); } }
Whether such inheritance is problematic, or that its own thinking is wrong.
Good around the problem, regardless of whether you are right or wrong, if you are now so difficult to clarify the problem, that in a few years or a change of a person, how to maintain the code?
I think it's not a good design even if it works.
If these classes require a common approach, inheritance is not the only way to implement it, and you can encapsulate these methods into stateless helpers, which are used in these classes separately.
Oranews::getlist () GetList () Now that you can allow static method calls, you can simply put them outside the class and package them separately.