In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.
A specification pattern outlines a business rule that is combinable with other business rules. 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 or inversion of control, have its state altered in order to become a delegate of other classes such as a persistence repository.
As a consequence of performing runtime composition of high-level business/domain logic, the Specification pattern is a convenient tool for converting ad-hoc user search criteria into low level logic to be processed by repositories.
Since a specification is an encapsulation of logic in a reusable form it is very simple to thoroughly unit test, and when used in this context is also an implementation of the humble object pattern.
| Expression | What it does |
|---|---|
${parameter:-defaultValue} |
Get default shell variables value |
${parameter:=defaultValue} |
Set default shell variables value |
${parameter:?"Error Message"} |
Display an error message if parameter is not set |
${#var} |
Find the length of the string |
${var%pattern} |
Remove from shortest rear (end) pattern |
${var%%pattern} |
Remove from longest rear (end) pattern |
${var:num1:num2} |
Substring |
${var#pattern} |
Remove from shortest front pattern |
${var##pattern} |
Remove from longest front pattern |
${var/pattern/string} |
Find and replace (only replace first occurrence) |
${var//pattern/string} |
Find and replace all occurrences |
${!prefix*} |
Expands to the names of variables whose names begin with prefix. |
${var,}<br>${var,pattern} |
Convert first character to lowercase. |
${var,,}<br>${var,,pattern} |
Convert all characters to lowercase. |
${var^}<br>${var^pattern} |
Convert first character to uppercase. |
${var^^}<br>${var^^pattern} |
Convert all character to uppercase. |