simulating object upcasting to an interface in PHP 4

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lawrence

    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("Data baseObject");
    myMaskObj->query("SELEC T * 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?
Working...