|  | Posted by Jerry Stuckle on 08/09/06 11:50 
wildernesscat wrote:> Hi Jerry,
 >
 >
 >>You can use is_a() as Marcin suggested.  But what's to stop me from
 >>creating my own class 'A'?
 >
 >
 > As I told Marcin, is_a() will not be of much use here. I need an
 > in-depth comparison, and not just resemblance in names.
 >
 >
 >>The real question is - why do you need this "feature"?  It violates
 >>several principles of OO.
 >
 >
 > Actually, I don't think that I violate any major OO principles. This is
 > almost like asking an object whether it supports certain interfaces.
 > I'll pinpoint my question. I want to know whether a certain object has
 > the _public_ properties of a given class. Does that make sense? Suppose
 > I have an object that has public properties $aaa, $bbb, and $ccc - I'd
 > like to know whether class A also has them.
 >
 >
 >>OO principles include that you don't care WHAT the object is - all you
 >>care about is its interface (functions).  If you need to depend on a
 >>specific class, you need to rethink your design.
 >>
 >
 >
 > Regards,
 > Danny
 >
 
 Danny,
 
 Again, that's a completely different question.
 
 No, there's nothing wrong to determine of a class supports specific
 properties.  But that's not the same as expecting a specific class.
 
 And in many cases classes shouldn't have public properties - they should
 have private properties and public access methods.  It isolates the
 interface from the implementation.
 
 I see a lot of public properties in PHP code - mainly because before
 PHP5 you couldn't define private properties.  However, if you look at
 C++, Java and Smalltalk, you'll find almost no public properties - only
 methods.
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |