473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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?
Jul 17 '05 #1
0 1602

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
Lets suppose I have an class called DatastoreSelect. It has a method called getNextRow(). This method is not abstract, it is fully implemented. It also has a method called setInfoToBeSought, which...
2
by: Judith | last post by:
Hi there everyone I've got: class A { ... }; class B : public A { ... }
12
by: cppaddict | last post by:
Hi, I know that it is illegal in C++ to have a static pure virtual method, but it seems something like this would be useful when the following 2 conditions hold: 1. You know that every one...
4
by: juli jul | last post by:
Hello, I did the following with Class A which is a parent and B inherits from it: B b1=new B(); A a1=new A(); a1=b1; Is it an upcasting in c#? Thank you!
5
by: Mark | last post by:
I can't seem to get this subclass to upcast to a baseclass... see comments below #include <cstdlib> #include <iostream> #include "Base.h" #include "Sub1.h" using namespace std;
3
by: mati-006 | last post by:
Hi, I think the code will be the best way to explain what I mean: #include "arglib/arg_shared.h" class base { public: base() {} virtual ~base() {} };
2
by: bg_ie | last post by:
Hi, Lets say I have an class called Base which is inherited by a class called Top. Now lets say I want to assign an object of type Base to an object of type Top, how can I do this so that all...
0
by: Juha Nieminen | last post by:
If I'm not mistaken, general OOP wisdom says that upcasting should usually be avoided if possible. I have a situation, however, where I can't think of a better way than upcasting for this specific...
5
by: Xu, Qian | last post by:
Hello All, I have some problem by simulating a link click using javascript. The webpage uses a js-library named interface (jQuery like) ------------------------------ <a id="foo" href="#">Try...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.