simulating object upcasting to an interface in PHP 4

This is a discussion on simulating object upcasting to an interface in PHP 4 within the PHP Language forums, part of the PHP Programming Forums category; In Java one is supposed to upcast an object to its interface whenever appropriate: MyInterface customers = new MySpecificClass(); The idea ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-11-2004
lawrence
 
Posts: n/a
Default simulating object upcasting to an interface in PHP 4

In Java one is supposed to upcast an object to its interface whenever
appropriate:

MyInterface customers = new MySpecificClass();

The idea is that if later one wants to change the specific
implementation one only has to change a few lines, possibly just the
one line above. Thus the code becomes more flexible.

Is it right to say that there is no way to do this in PHP? I've taken
to simulating the same by using one object as a mask that sets and
then uses another object:

myMaskObj = new MaskDatabase();

myMaskObj->setDbObj("DatabaseObject");
myMaskObj->query("SELECT * FROM content WHERE type='comments'");

MaskDatabase has a method called "query" which simply passes the query
along to DatabaseObject which also has a method called query.

Other ideas?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0