Thursday, April 24, 2008

Pattern - 1: Specification


Name: Specification (Also known as Type and Actual)

Intent: To Factor out unchanging facts from their occurrences in actual instances.

The idea is to separate type of things from actual things. This pattern reduces rdundencies as it factors out specification facts from actual class which realises them. The specification class would mostly display little or no behavior, will have static instance populations. Updating only the specification classes would remove the need to update all the instances.

A Specification pattern outlines a unit of business logic that is combinable with other business logic units. In this pattern, a unit of Business Logic inherits its functionality from the abstract aggregate Composite Specification class. The Composite Specification class has one function called IsSatisfiedBy that returns a boolean value. After instantiation, the specification is 'chained' with other specifications, making new specifications easily maintainable, yet highly customizable business logic. Furthermore upon instantiation the business logic may, through method invocation , have its state altered in order to become a delegate of other classes such as a persistence repository.


No comments: