Re: flyweight object equivalence

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Jason S <jmsachs@xxxxxxxxx> wrote:
Hmm. After embracing the idea of flyweights (multiple small COM
objects used to access/represent a common underlying shared object)
I'm running up against a subtlety, namely I am not sure how to provide
the functionality for testing equality.

If I wanted to compare this information in C++, it's easy; I just
compare these 2 items with their appropriate operator ==() methods.

But how do I compare flyweights for equivalence in COM?

Well, if it's meaningful for your COM objects to be tested for equality,
you would have to provide an Equals method on one of the interfaces they
implement. Just like you provide operator== method on your C++ objects.

I'm not even sure what method
to provide in an IDL file to allow objects to be compared.

HRESULT Equals([in] IMyInterface* other, [out, retval] VARIANT_BOOL
ret);

It's just an example. The method doesn't have to be named Equals, and
doesn't have to have this exact signature. There is no standard for such
a method, you are free to design whatever makes sense.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Integer 128 != Integer 128 ??
    ... You shouldn't use the == to compare values of Integers or other objects, ... use it only for numerical primitives (or testing whether an object is ... With Integers and other subclasses of Number, use the equals method for ... testing equality and the compareTo method if you need to know not only ...
    (comp.lang.java.programmer)
  • Re: JDBC compare the content of two tables
    ... I want to use getObject method to get the value of each column, ... then use equals method of java.lang.Object to compare two columns' values. ... representation for NaN or not. ...
    (comp.lang.java.help)
  • Re: Newbie question about object comparisons
    ... > However, in the business problem I'm trying to solve, the 'keys' are ... In that case I amend my recommended solution: use the Equals method. ... the correct Equals to call to compare your two keys. ...
    (microsoft.public.dotnet.csharp.general)
  • Re: Sorting arrays (again)
    ... It just tells you that though the compilation went through, ... javac command to uncheck -Xlint? ... To what am I supposed to compare? ... And now I can implement the equals method as well. ...
    (comp.lang.java.help)
  • Re: implicitly handle operator == when class overrides Equals method
    ... operators when my class overrides the Equals method and implements the ... Then compare for equality. ... object obj1 = InFac1; ... object obj2 = InFac2; ...
    (microsoft.public.dotnet.languages.csharp)