Specification Design Pattern

Definition

The central idea of Specification is to separate the statement of how to match a candidate, from the candidate object that it is matched against. The specification responsibility is to identify an object that satisfies it, and to combine with other specifications in various ways that support that basic responsibility (Eric Evans & Martin Fowler)

Applicability

  • You need to select a subset of objects based on some criteria, and to refresh the selection at various times.
  • You need to check or validate that only suitable objects are used for a certain purpose.
  • You need to describe what an object might do, without explaining the details of how the object does it, but in such a way that a candidate might be built to fulfil the requirement.


Consequences

  • Decouple the design of requirements, fulfilment, and validation
  • Allows clear and declarative system definitions

Downsides

  • There lacks a well-defined purpose for this pattern, and there's no guide when to implement it or not.
  • Separate classes for each part of the specification fragments what could be a cohesive object.

Sample Code

Generic Specification
Gold Customers Specification Sample

    Comments

    1. For iPhone customers, click on the square field with the arrow in the middle of|in the midst of|in the course of} the underside bar, and scroll 배당 토토 down to pick out} ‘Add to Home Screen’. The various is to play in browser on the html5 cellular version of the casino web site. Ct. 1461, (emphasizing that “federal policy” is to “respect the policy selections of the individuals of every State on the controversial problem of gambling”).

      ReplyDelete

    Post a Comment

    Popular Posts