On  Jul 1, 2009, at 10:05, Galder Zamarreno wrote:


3 - SearchableCache: -

Should the name of this class be changed? I don't think so but if anyone
has any ideas ...

Here's my point of view:

createQuery() looks to me like factory method and so I think it would suit more a factory interface, i.e. QueryFactory? rather than in an extension of Cache.

IMO, extending Cache interface would make sense if you're gonna add an operation against the searchable or queryable cache itself, such query(). But this method kind of implies that you actually execute the query against the cache, so you'd imagine taking a CacheQuery as parameter. Bearing in mind my limited knowledge of how users use JBC Searchable, I dunno if having such method makes sense or not. If it does not, not a problem. Stick with a QueryFactory interface that has a create() method that returns Query (or CacheQuery) and that's it.


Well except that your API will be just verbose and complex to use.
What's better?

List<Item> results = cache.createQuery(luceneQuery, Item.class).setMaxResults(20).getResultList();
or
Query q = cache.getCacheManager().getQueryFactory().create(luceneQuery, Item.class)..setMaxResults(20);
List<Item> results = cache.query(q);

in other words, who cares if it's a factory, a factory factory or an abstract factory factory factory. People just want to create a query and get the result list