<div dir="ltr">Awesome - thank you (and everyone) for taking the time to explain.</div><div class="gmail_extra"><br><div class="gmail_quote">On 16 July 2015 at 13:40, Tom Stuart <span dir="ltr"><<a href="mailto:tom@codon.com" target="_blank">tom@codon.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 16 Jul 2015, at 13:03, Duncan Stuart <<a href="mailto:dgmstuart@gmail.com">dgmstuart@gmail.com</a>> wrote:<br>
> Because ordering on Dates in Ruby requires actual Dates and not Date-like things, forcing us into an undesirable implementation?<br>
<br>
</span>Yes, I think that’s the underlying problem.<br>
<br>
However, many of the techniques for “eliminating” nil checks or instance-of checks don’t really eliminate them, only encapsulate them. The condition that drives the decision about which class to instantiate (or whatever) has to go somewhere. So, for me, the principle is about doing those checks sooner, so that the rest of the system can lean on polymorphism — which is just a different kind of conditional that gets hidden from the caller — instead of having to be directly aware of the condition.<br>
<br>
For example, you could “eliminate” the checks here by having two different classes of date-ranking object for events with & without dates, and designing their #<=> methods so that the two kinds of object interoperate nicely during a heterogeneous sort, etc. But you’d still need a condition somewhere to decide which of those classes to use for ranking a given event.<br>
<br>
So it is a trade-off, and the guiding principle is how tightly you want to contain the information that an event may be missing its date.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/pipermail/chat-lrug.org</a><br>
Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br>
List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" rel="noreferrer" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</div></div></blockquote></div><br></div>