Comparison
Metric definitionvsSpecification pattern
Metric definition
two dashboards show different revenue because one includes refunds and neither of them says so anywhere.
The precise, written statement of how a business measure is computed, including what is excluded. Most metric disagreements are not disputes about a number but discoveries that two people were computing different things, and the definition is what makes that discoverable in seconds. It has to live where it is executed rather than in a wiki, otherwise the wiki becomes the aspirational version.
Full entry →Specification pattern
the rule for what counts as a lapsed customer is one object, used both to filter the query and to check one in memory.
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.
Full entry →