What is a pattern?
A Pattern would be described as a well tried-solution to a real problem of a particular context.
Patterns are optimal solutions to common problems. As common problems are tossed around a community and are resolved, common solutions often spontaneously emerge. Eventually, the best of these rise above the din and self-identify and become refined until they reach the status of a Design Pattern.
Patterns are atomic in that they can be grouped to form more complex patterns: a chair pattern nests within a dining room pattern that nests within a house pattern that nests within a town pattern.
One idea that distinguishes Patterns from simple prescriptions is that Patterns never lose sense of their context; they describe things that work together and the rules that govern those collections.
Example of a pattern;
Problem name: Getting on the property ladder
Authors: Steven. J. Kintu
Creation date: 13-02-07
Keywords: [save no matter how much you bring in, retain your job at all costs]
Intent:Keep the interest in the dream. Don’t give up stay focused don’t let negative thoughts wash your dream away
Context:
Suppose you are thinking of owning your own house, as soon as after you have graduated. With that part time job you have that you have been doing through out your course. Make a regular saving out of it into an ISA [instant savings account]. Ignore any student loans and debts, as long as you have an income save up ₤ 3000 a year, if you can into your ISA. Its tax free with at least 4% p.a. team up with one of your close ones if you opt for a joint mortgage. With this you could end up with ₤ 6000 between the two of you on your ISA accounts. Do this for two years and have almost ₤12,500 between the two of you. That’s good enough to be your initial deposit on an average told on two bedroom flat. With this under your arms hold on to it for two years and you’ll notice an increase in value upon your property incurring the same expense on it as you would while paying rent.
Forces
We want to get on the property ladder.
We don’t want to compromise the limit we are set for monthly rent payment.
solution:Use an ISA to save as it’s a relatively high interest paying account.
Example/ known use:The bank that holds your ISA account will favor your mortgage intentions.
patterns need to be documented;
-for refferal reasons by designers to acquire knowledge of how to reapply them and use them.
-to support reuse in design and boost confidence in reapplication of the pattern by future users
-to present optimized solutions to particular partial design problems.
-to help make the used code easier to understand for intending users of the pattern
The general form for documenting patterns is to define items such as:
The motivation or context that this pattern applies to,
Prerequisites that should be satisfied before deciding to use a pattern,
A description of the program structure that the pattern will define,
A list of the participants needed to complete a pattern,
Consequences of using the pattern, both positive and negative and
Examples
Qualities of a pattern
Encapsulation and Abstraction
Each pattern encapsulates a well-defined problem and its solution in a particular domain. Patterns should provide crisp, clear boundaries that help crystallize the problem space and the solution space by parceling them into a lattice of distinct, interconnected fragments. They also serve as abstractions which embody domain knowledge and experience, and may occur at varying hierarchical levels of conceptual granularity within the domain.
Openness and Variability
Each pattern should be open for extension by other patterns so that they may work together to solve a larger problem. A pattern solution should be also capable of being realized by an infinite variety of implementations (in isolation, as well as in conjunction with other patterns).
Generatively and Compos ability
Each pattern, once applied, generates a resulting context which matches the initial context of one or more other patterns in a pattern language. These subsequent patterns may then be applied to progress further toward the final goal of generating a "whole" or complete overall solution. "Patterns are applied by the means of piecemeal growth. Applying one pattern provides a context for the application of the next pattern." But patterns are not simply linear in nature, more like fractals in that patterns at a particular level of abstraction and granularity may each lead to or be composed with other patterns at varying levels of scale.
Equilibrium
Each pattern must realize some kind of balance among its forces and constraints. This may be due to one or more invariants or heuristics that are used to minimize conflict within the solution space. The invariants often show an underlying problem solving principle or philosophy for the particular domain, and provide a rationale for each step/rule in the pattern.
The aim is that, if well written, each pattern describes a whole that is greater than the sum of its parts, due to skillful choreography of its elements working together to satisfy all its varying demands.
What a pattern comprises of;
• The pattern name: This could be a noun for pattern names, but short verb phrases can also be used.
•The problem is often stated as a question or design challenge.
• The context: A description of the context in which the problem might arise, and to which the solution applies.
• The forces: The forces describe pattern design trade-offs; what pulls the problem in different directions, toward different solutions?
• The solution: The solution explains how to solve the problem, just as in the emboldened section of an Alexandrian pattern.
•Why does this pattern work? What is the history behind the pattern? We extract this so it doesn’t “clutter” the solution. As a section, it draws attention to the importance of principles behind a pattern; it is a source of learning, rather than action.
• Resulting context: This tells which forces the pattern resolves and which forces remain unresolved by the pattern, and it points to more patterns that might be the next ones to consider.
http://www.designpattern.lu.unisi.ch/
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/patterns/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment