<div dir="ltr">Also, a bit curious:<br><br>Equality {<br> Equals(left interface{}, right interface{}) bool<br>}<br><br>What does the implementation of this look like? Its usage? Because now to achieve your point 4) we've moved the responsibility of determining equality from the object in question to some external equality-checker. How does the equality-checker know about the various types it has to support?<br><br>S,<br>ALR<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 11:30 AM, Andrew Lee Rubinger <span dir="ltr"><<a href="mailto:alr@redhat.com" target="_blank">alr@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Java may have made an odd design design by putting "boolean equals(Object)" in the root Object class as a mechanism to test equality by value, but there's also:<div><br></div><div> <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html" target="_blank">https://docs.oracle.com/<wbr>javase/8/docs/api/java/lang/<wbr>Comparable.html</a></div><div><br></div><div>This approach handles not just equals but also greater/less than comparisons for types that have ordered values. You could retrofit it to return an enum type instead of an int for better clarity.</div><div><br></div><div>Something to consider :)</div><div><br>S,</div><div>ALR</div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 10:19 AM, Konrad Kleine <span dir="ltr"><<a href="mailto:kkleine@redhat.com" target="_blank">kkleine@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Thomas,<div><br></div><div>thanks for not pointing in my direction :)</div><div><br></div><div>I can't wait to see a PR for this.</div><div><br></div><div>Regards,</div><div>Konrad</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Sep 22, 2016 at 3:32 PM, Thomas Mäder <span dir="ltr"><<a href="mailto:tmader@redhat.com" target="_blank">tmader@redhat.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div bgcolor="#FFFFFF" text="#000000">
<p>Hi folks, <br>
</p>
<p>some time back, we have introduced the "Equaler" interface. I
believe we're going down the wrong path with this: Java got this
wrong initially and we still suffer the consequences. Equaler
looks like this:</p>
<p>type Equaler interface {<br>
Equal(Equaler) bool<br>
}</p>
<p>There are a couple of drawbacks to this approach:</p>
<ol>
<li>There can only be a single implementation of Equals for all
time. But this too restrictive: for example, I might want to
include the version field in a struct in the comparison for some
cases, in other cases I simply don't care. Generally, there can
be many equivalence relationships for a given set of objects.
For all we know, we might consider two objects equal if they
have the same color.</li>
<li>You can't compose equality with this implementation<br>
In Java, this has given rise to classes like "EqualsBuilder"
that allowed to do exactly that.<br>
</li>
<li>We can't implement equality based on interfaces<br>
We'd have to reimplement equality for every struct (which is the
first parameter).</li>
<li>You always have to check for null before calling Equals()</li>
</ol>
<p>So I propose to rewrite the interface to :</p>
<p>Equality {</p>
<p> Equals(left interface{}, right interface{}) bool<br>
</p>
<p>}</p>
<p>I think it would make sense that I prepare a PR to illustrate my
approach porting the current implementations in the "models"
packe. A POC shouldn't take too long. <br>
</p>
<p>thoughts?</p><span><font color="#888888">
<p>/Thomas<br>
</p>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
almighty-public mailing list<br>
<a href="mailto:almighty-public@redhat.com" target="_blank">almighty-public@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/almighty-public" rel="noreferrer" target="_blank">https://www.redhat.com/mailman<wbr>/listinfo/almighty-public</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
almighty-public mailing list<br>
<a href="mailto:almighty-public@redhat.com" target="_blank">almighty-public@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/almighty-public" rel="noreferrer" target="_blank">https://www.redhat.com/mailman<wbr>/listinfo/almighty-public</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div data-smartmail="gmail_signature"><div dir="ltr">Red Hat Developer Programs Architecture<div>@ALRubinger</div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Red Hat Developer Programs Architecture<div>@ALRubinger</div></div></div>
</div>