8 apr 2006 kl. 19.04 skrev Erick Erickson:

I have to disagree.

Optimization where it really doesn't count is, in my experience, bad.
Period.

My intent was not to ephasise on optimization. The waste of clockticks is just a side effect from what I consider bad design. WildcardQuery and TermQuery do diffrent things. If I want to encapsulate the functions of both in one class I write a factory.

class TermOrWildcardQuery implements Query {
        private Query factory(Term t) {
if (t.termText.endsWith("*")) return new WildcardQuery(t); else return new TermQuery(t);
        }
}


I have never used such a factory, but my guess is that programmatically I would always know If I wanted to use a wildcard or not. So only when writing a primitive query parser for human entered text could I see the use for such a thing. Perhaps then it is then better to write a real parser/lexer using Antlr or JavaCC?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to