Thoughts on Qualifier Matching - microbean/microbean-settings GitHub Wiki

This page is in scratch stage; I'm exploring ideas clumsily with a lousy background in set theory so many of the things you read here may turn out to be wrong.

In no particular order:

  • Any empty set of qualifiers contains any other empty set of qualifiers, so matches it.
  • A single qualifier, a=b, contains an empty set of qualifiers, so matches it.
  • An empty set of qualifiers does not contain a single qualifier, a=b, so does not match it. Hmm. Or maybe it does, but badly.
  • A single qualifier, a=b, contains another single qualifier, a=b, so matches it.
  • A qualifier, a=b, does not contain another qualifier, c=d, so does not match it. But there are intersection issues here.

(Still in progress; this doesn't work like most DI situations, I don't think, which are subset-in-the-other-direction-based. Maybe what we're really looking at where settings and configuration is concerned is set intersections. For example, if a context path's qualifiers somewhere are {a=b}, and a value path's are {a=b, c=d}, at some hazy intuitive level {a=b} matches {a=b, c=d} (that's the ordinary DI principle: if you @Inject @Red Car, you could get a @Red @Racing Car). And at another hazy intuitive level a context path of {a=b, c=d} matches a value path of {a=b}, just not very specifically. That latter case doesn't work in "regular" DI: if you @Inject @Red @Racing Car you won't get @Red Car.)

Let's explore the intersection idea. I was never taught set theory so I'm like a middle-schooler here; bear with me.

For simplicity, let's reduce a=b to just A. a=c would be distinct anyway, so we can just call it B. And so on.

Another question in play is whether an empty bucket of qualifiers is the empty set (no qualifiers at all) or the universal set (a clumsy representation of all possible qualifiers). If it's the empty set, then {A}{} = {A}. If it's the universal set, then {A} = .

Maybe a good (relative, remember) score is intersection size minus difference size?

Context Value Intersection Intersection Size (IS) Difference Difference Size (DS) Score (IS - DS) Notes
{A} {A} {A} 1 {} 0 1 This one should win and is the highest score possible for this permutation.
{A} {} {} 0 {A} 1 -1 Yep; empty qualifiers are maximally generic.
{A} {B} {} 0 {A,B} 2 -2 Yep; just not a match at all. Have to capture that.
{A} {A,B} {A} 1 {B} 1 0 Hmm; A matched so I guess indeed this is less generic than row 2
{A} {A,B,C,D} {A} 1 {B,C,D} 3 -2
Context Value Intersection Intersection Size (IS) Difference Difference Size (DS) Score (IS - DS) Notes
{} {} {} 0 {} 0 0 Scores are relative, remember, so 0 would be the highest you could get in this permutation.
{} {A} {} 0 {A} 1 -1 Yep; less than the highest