Design patterns·Modelling the domain
the rule for what counts as a lapsed customer is one object, used both to filter the query and to check one in memory.
Specification pattern
Also calledspecification, business rule object, predicate object
Encapsulating a business rule as an object that can answer whether a candidate satisfies it, and that can be combined with and, or and not. Its strongest form is one rule usable in two places — evaluated against an object in memory and translated into a query — which is what keeps the definition of 'lapsed' from existing twice. It is worth the machinery only when the rules are combined or reused; a single predicate is better as a method.