<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body 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>
<p>/Thomas<br>
</p>
</body>
</html>