If we are to explain the Specifications pattern, it would be; a logic that returns either true or false. The composite specification class has a standard method called isSatisfiedBy that returns the true or false values. This is done by checking given object to see if it satisfies the specifications set by us.

The scenario

You are selling your house and have some criterias that the user must meet in order to buy your house. The user must:

  • be minimum 18 years old (this is the legal requirement and won’t change)

  • have £500000.00 in his pocket (this can change at anytime based on the market)

  • must be alive (obviously!)

Example

#php

Specifications Design Pattern Example in PHP
2.20 GEEK