Skip to content
StackDecode
System Design
15. Software Design PatternsAnimated walkthrough

Specification Pattern

Reusable business rules as objects.

The idea

Each rule is a specification that can be combined with and, or and not.

Watch it work

The steps light up one at a time. Use the controls to pause or step through.

  1. 1Create a specification
  2. 2Combine specifications
  3. 3Test an object against it
  4. 4Reuse for queries
1/4

Step by step

  1. 1Create a specification
  2. 2Combine specifications
  3. 3Test an object against it
  4. 4Reuse for queries

Where it is used

Complex filtering rules.

Watch out for

Can be over-engineered.

Related