Design Patterns
A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise. The idea was introduced by the architect Christopher Alexander in the field of architecture and has been adapted for various other disciplines, including computer science
A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise. Each pattern describes a problem that occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice. The usefulness of speaking of patterns is to have a common terminology for discussing the situations designers already see over and over.
There are hundreds of books available and many times that of online articles discussing design patterns. The seminal work in the field is Design Patterns - GoF - Gamma, Helm, Johnson and Vlissides, 1995. It is not my intention here to replicate any of that work, only to show how design patterns can be applied using the SQL language. All of the examples I've seen have been for object oriented languages. Since the late 80's when I was programming in ANSI C my contention has been that you can, and should, use object oriented principles in any language. Here I will show some examples of the implementation of certain design patterns, an object oriented technique, in the SQL language.
Facade pattern - Provides a simplified interface to a larger body of code.
Bridge pattern - Decouples an interface from its implementation so that the two can vary independently.
Chain of Command pattern - The chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain.
Anti-Patterns
There must be at least two key elements present to formally distinguish an actual anti-pattern from a simple bad habit, bad practice, or bad idea:
Some repeated pattern of action, process or structure that initially appears to be beneficial, but ultimately produces more bad consequences than beneficial results, and
An alternative solution exists that is clearly documented, proven in actual practice and repeatable.
Reference
copyright Katherine Elizabeth Lightsey 1959-2013 (aka; my life)
"Set patterns, incapable of adaptability, of pliability, only offer a better cage. Truth is outside of all patterns." - Bruce Lee, Tao of Jeet Kune Do