On Monday, March 24, 2014 11:42:39 AM UTC-4, Sam Berlin wrote: > > It's very unlikely to change in future versions. We'd break all our > servers if we did. I think the more likely fix is that we document it. >
You make an interesting point indirectly here, which is a general limitation of SetBinder and so forth as well: No ordering. In theory, it's great to say things have an undefined order. In practice, you just wind up accidentally depending on the undocumented order of things. I've seen that happen with Swing's event listeners (change look and feels at runtime and suddenly the application's listeners are called before the look and feel's), and various other pieces of code (things where you factor what would be a spaghetti of if/then/else's into a tree of objects that accept or don't accept some parameters). There are two general ways frameworks solve this: - Provide a way to include ad-hoc ordinals, suggest the application author space them so they can add elements in-between existing ones, and document whether ones without an ordinal (if such are allowed) sort to the top or bottom - Provide a way to specify "constraints" - comes-before and comes-after references to other elements, which result in a node/edge graph you can do a topological sort on The ordinal approach is usually easier to maintain and debug. The few times I've used set binders (because of this limitation), I usually wind up annotating classes with an @Ordinal annotation, and use those to sort the result into a List. Which is a rather silly bit of boilerplate to keep repeating. Given that interceptors, and common cases of set binding routinely *have* order which people will depend on (whether they know it or not), perhaps this is a thing Guice ought to explicitly solve. -Tim -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/d/optout.
