If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Using Interfaces to design an application

HI

I am trying to implement a Short Message Service or as you call it Texting service for mobiles into my PHP application that will send sms to my customers using various SMS providers (the real case senario is diff but here I am trying my best to explain my question, so pls bear with this SMS example only).

Now, I am told to follow design patterns (not sure which one as I am new to patterns) to integrate it.

I would create an abstract SMS class (or whatever it makes sense to call it) which might implement one or more interfaces if it makes sense -- so far I've not seen any reason to have any interfaces. (That does not mean there is not any reasons, just that I'm not yet aware of them from the info provided.)

Your concrete Verizon, ATT, etc. classes would extend the abstract class, overriding any methods/properties that need to be different than what is defined in the abstract class, or defining any methods defined as "abstract" in that abstract class.

You could then look up the Factory Pattern (or Abstract Factory Pattern) and look at how to use that to instantiate the proper concrete class at run-time.

"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation

Interfaces are much like abstract classes but with one major difference. They doesn't have a parent-child relationship. So what that means is that you can create classes of totally different ancestry and yet they will contain the same methods defined by the interface they implement.

One example. You can have two objects, let's say a pc and a watch. This two objects have nothing in common. But let's say that you create an online store and want to be able to sell those two products. You can implement Sellable interface and define a method which both classes (pc class, and watch class) must implement.