Jump to content

Talk:Criteria Pattern

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Bug in implementation?

[edit]
   public List<E> MeetCriteria(List<E> entities)
   {
      var result = _criteria.MeetCriteria(entities);
      // If it returns 1 is because only 1 met the criterion
      // and the inherited ands are not executed
      // If it returns 0 is because none met the criterion
      // and the inherited ands are not executed
 
      if (result.Count == 0 || result.Count == 1)
         return result;
 
      return _otherCriteria.MeetCriteria(result);
   }

Surely || result.Count == 1 is a bug: if we don't check any result against _otherCriteria how can we say it meets both? — Preceding unsigned comment added by 60.241.96.32 (talk) 10:06, 22 December 2012 (UTC)[reply]

Invented by the individual that wrote the article?

[edit]

I'd have to say this looks a lot like the http://wiki.riteme.site/wiki/Specification_pattern for which credit goes to Martin Fowler in 2004 (at least). — Preceding unsigned comment added by 60.241.96.32 (talk) 08:29, 23 December 2012 (UTC)[reply]

Was looking for a solution to this problem and found this article. Did some more research as I could not believe that this common problem has no big article covering it. Found out that Fowler calls this Specification Pattern. The code in the article mostly implements http://martinfowler.com/apsupp/spec.pdf compare page 12. The description is a subset of the Specification pattern. Maybe some experienced user can create a redicrect. — Preceding unsigned comment added by 109.192.57.59 (talk) 22:18, 29 September 2014 (UTC)[reply]

+1 for creating a redirect KSiimson (talk) 07:49, 13 September 2016 (UTC)[reply]