Code Design Question
Let’s suppose I’m using a third party API class, oh, I don’t know, let’s say “Facebook.” I’ve got a $facebook=new Facebook; and $facebook->api_client->bar(), et cetera. And suppose, I want to do something with it, but I’m using a class too. Let’s say, I want a class “Pets.” I’ll need to use the facebook class for communicating with the facebook servers and configuring stuff.
Which is the “Best Practice”?
- extend the facebook class like “class Pets extends Facebook” …
- use a facebook variable in the Pets class – $pets=new Pets; $pets->fbook =& $facebook;
- Don’t tie the two objects together
What do you think results in the most clear code?
