it:ad:patterns:specification_pattern

IT:AD:Patterns:Specification Pattern

Summary

Used extensively in App.Domain.Repositories.

It's separating the decision as to which object types should be selected in a query from the object that makes the selection.
Writing code like this allows reusing a Domain Layer Specification within a repository as a method for querying:

IEnumerable<Customer> customers = customerRepository.GetBySpec(IsPremiumCustomerSpecification);

That said, the original MF pattern was written prior to LINQ.

  • Pros:
    • End user can built up and save precompiled Queries.
      • “Select all (Invoices with Total > 300.00) AND (Country = GB)”
      • We decouple the design of requirements, compliance and validation.
      • ??? EXAMPLE ???
      • It allows definition of clear and declarative queries
      • Instead of Linq all over the Application Layer, untested until run, Queries can be tested in isolation, and reused.

      ## Recipe ##

[TODO]

  • /home/skysigal/public_html/data/pages/it/ad/patterns/specification_pattern.txt
  • Last modified: 2023/11/04 03:29
  • by 127.0.0.1