Nil in an index

Chris Muller asqueaker at gmail.com
Sun Jan 13 03:48:11 UTC 2008


The indexes provided with Magma are really just simple examples.
Robust applications will almost certainly want to define their own
custom indexes.

That is your path to a clean solution.  Make your own DateIndex that
accepts a nil.  Just override #canIndex: in addition to
#indexHashForIndexObject:, et al...


On Jan 11, 2008 9:43 AM, Norberto Manzanos <nmanzanos at gmail.com> wrote:
> Hi!
>
> Is it a good idea avoid nil in magma indexes?
> This question rised when I tried MaDateIndex. Until this moment, I used
> String or Integer indexes having care to answer allways a String (an empty
> string if the object is nil) and an  Integer (a zero if nil). But with dates
> there is a conceptual problem: there is not a null date. In some
> applications, business stuff, for example, you can think in an ovbiously
> unused date (01-01-1500, for example) that acts as a null date. It's a
> little dirty, but it would work. But in other applications every possible
> date has a meaning. And if the object could be inexistent in some cases, you
> have no choice: it's nil.
> That's my case, and I'm forced to use a StringIndex, converting the dates to
> Strings, answering an empty string if the object is nil. That's really
> dirty.
> Would'nt be better if magma indexes just ignore nil objects? Is it a
> requirement for magma that every object from a MagmaCollection must be
> present in all indexes?
> I hope there is something I misunderstood and there is a more elegant
> solution.
>
> Regards
> Norberto
>
>
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>
>


More information about the Magma mailing list