[LRUG] Comparable Null Objects

Sleepyfox sleepyfox at gmail.com
Sat Jul 18 03:54:11 PDT 2015


Thinking out loud:

Another use of NullDate with sorting might be to place them 'now', as
if they are placed at the beginning (of time) or end then they may
never get seen by the user.

On the other hand, placing them in a totally separate piece of the UI
may be a better course of action, in which case null dates should be
filtered and never appear in the sorted chronological view.

I'm guessing that there are requirements that are not being expressed
here: why is it that some events do not have a date? Is it that they
are ongoing or repeating events? Or is it that they are awaiting
scheduling? The business meaning behind not having a date will dictate
how you wish to deal with them.

Personally I would feel uncomfortable mixing in 'date-less events'
with the general 'date-ful' events; whenever I see something like this
there is generally a more elegant (domain) solution that makes all the
complexity go away...

Fox
--
"What does the @sleepyfox say?"


On 17 July 2015 at 14:18, Andrew Premdas <apremdas at gmail.com> wrote:
> The use of a NullDate is not incompatible with something wanting to sort
> Events in a particular way. If we think about how NullDate's should be
> sorted we can see a very limited number of possibilities
>
> - place at the end
> - place at the beggining
>
> So our NullDate could support a convention when implementing comparable to
> make one of these choices and perhaps allow configuration to choose the
> other. This would allow Events (and lots of other stuff) to use NullDates,
> and allow Event collections to control how Date's effect the ordering.
>
> I wonder should this functionality actually be in Date?
>
> On 17 July 2015 at 11:51, James Mead <james at floehopper.org> wrote:
>>
>> I just came across the undocumented Date::Infinity class [1] which
>> might be of some relevance to this thread.
>>
>> [1]:
>> https://github.com/ruby/ruby/blob/c8b3f1b470e343e7408ab5883f046b1056d94ccc/ext/date/lib/date.rb#L7..L58
>>
>> On 17 July 2015 at 00:53, Paul Makepeace <paulm at paulm.com> wrote:
>> > On Thu, Jul 16, 2015 at 3:24 PM, Stephen Best <bestie at gmail.com> wrote:
>> >>
>> >> events.sort_by { |e|
>> >>   e.date { heat_death_of_the_universe }
>> >> }
>> >>
>> >
>> > This to me is the clearest of the proposals (Tom's role idea is cool
>> > too).
>> >
>> > For a null object you could also use... nil
>> >
>> >   events.sort_by { |e|
>> >     e.date || date_that_sorts_at_the_end  # (named to be clearer about
>> > intent)
>> >   }
>> >
>> > The whole discussion has been really interesting!
>> >
>> > Paul
>> > _______________________________________________
>> > Chat mailing list
>> > Chat at lists.lrug.org
>> > Archives: http://lists.lrug.org/pipermail/chat-lrug.org
>> > Manage your subscription:
>> > http://lists.lrug.org/options.cgi/chat-lrug.org
>> > List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>> _______________________________________________
>> Chat mailing list
>> Chat at lists.lrug.org
>> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
>> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
>> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
>
>
> --
> ------------------------
> Andrew Premdas
> blog.andrew.premdas.org
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>



More information about the Chat mailing list