Design Patterns • I Alexei Khorev Design and patterns Designs humans do Architectural design Christopher Alexander Great architecture What is DP? Patterns in Software Patterns and Idioms DPs for Software DP Misconceptions 15.1 Design Patterns • I Introduction: Christopher Alexander’s Vision COMP2110/2510 Software Design Software Design for SE September 10, 2008 Alexei Khorev Department of Computer Science The Australian National University
32
Embed
Design Patterns I - Introduction: Christopher Alexander's ...courses.cecs.anu.edu.au/courses/archive/comp2110.2008/lectures/lec... · Christopher Alexander Great architecture What
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.1
Design Patterns • IIntroduction: Christopher Alexander’s Vision
COMP2110/2510Software DesignSoftware Design for SESeptember 10, 2008
Alexei Khorev
Department of Computer Science
The Australian National University
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.2
1 Design and patterns
2 Designs humans do
3 Architectural design
4 Christopher Alexander
5 Great architecture
6 What is DP?
7 Patterns in Software
8 Patterns and Idioms
9 DPs for Software
10 DP Misconceptions
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.3
Design and patterns
What “design” means?
1 plan or drawing produced to show the look and function orworkings of a building, garment, or other object before it isbuilt or made
2 purpose, planning, or intention that exists or is thought toexist behind an action, fact, or material object
What “pattern” means?
1 an arrangement or sequence regularly found in comparableobjects or events
2 a regular and intelligible form or sequence discernible incertain actions or situations
3 a model or design used as a guide in needlework and othercrafts (which infers that software design is a craft)
Design and patterns are thus related. ,
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.4
Design as human activity
Design activitities humans are involved in
• In civil engineering — buildings, bridges, roads,. . .
(static constructions)
• In mechanical engineering — vehicles of every kind
(dynamic constructions)
• In electrical engineering — electrical/electronic devices
• In architecture (same objects as in civil engineering,
but a different aspect)
• In industrial design in broad sense (includes HCI)
• In political and social engineering
(regime changes, “export of democracy”)
• In software creation (software design)
Some types of design are governed by fundamental laws
(mechanics, electricity, material physics and chemistry), others are
subject to rules which humans (may think to) create. The latter
makes architecture and software design close.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.5
Why architecture is different?
Faced with enormous challenges, software developers wanted to
make the software design process more reliable and well defined,
more ‘scientific’, like in other design activities, “. . . , like X, where Xis any design-intensive profession with a longer and apparentlymore successful history than software” (Doug Lea). Most designs
“with a longer and more successful history” are well (sort of)
founded because they are rooted in the laws and properties of the
natural world.
The architectural design (understood in a broad sense as design
of environment for human existence — buildings, urban area and
artificial landscape) on the other hand has been always
considered both a methodical process and an art form.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.6
Design so beautiful
“I call architecture frozen music”
(Johann Wolfgang Goethe)
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.7
Architecture and software
Introduction of the object paradigm in 1980s created big
challenges for its effective use. Original focus “find-the-object”
without due emphasis on interaction and relationship between
classes and objects was not enough to capture “rich structures of
our increasingly complex systems”.
In 1987, Ward Cunningham (CRC cards, Wiki) and Kent Beck
(CRC too, Extreme Programming, JUnit) introduced the ideas of
design patterns to create Smalltalk programming environment.
The idea of design patterns was introduced not by a software
developer, but by an architect, Christopher Alexander. When he
started the professional career (early 1960s), architects began
using computerized tools and computer-like algorithms in building
design of modular construction. Alexander soon convinced himself
that this approach was threatening the architectural quality —
beauty, elegance, harmony were disappearing, and living
environment got dehumanized.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.8
Christopher Alexander
born in Austria
educated in UK
lives and works in USA
professor emeritus of architecture
(in Berkeley, California)
Ch. Alexander is not an ordinary architect. Early in his life he was
a mathematician: “played with operations research, linearprogramming, all the fascinating toys, which mathematics andscience have to offer us, and tried to see how these things cangive us a new view of design, what to design, and how to design”.He later “realized that this view is essentially not productive, andthat for mathematical and scientific reasons, if you like, it wasessential to find a theory in which value and fact are one, in whichwe recognize that here is a central value, approachable throughfeeling, and approachable by loss of self, which is deeplyconnected to facts, and forms a single indivisible world picture”(from The Timeless Way of Building).
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.9
Alexander and Software Engineering
His books are (or, at least, used to be) more popular among
software designers than among fellow architects:
• A Pattern Language, 1977 (contains 253 patterns — thank
goodness we are not studying architecture!)
• The Timeless Way of Building, 1979
• The Nature of Order, 4 books 199x
Wiki claims that his influence extends much further then OO
Design Patterns: back in 1960s, another his book Notes on theSynthesis of Form was a required reading for researchers in
computer science (in MIT, at least). And that the very Wiki (Web
2.0) was invented by Ward Cunningham as a medium for hosting
The Hillside Group — the internet-based community to promote
the Design Pattern philosophy.
One of the most successful computer game creators, Will Wright,
ascribes the origin of the Sims games to Alexander’s influence.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.10
Patterns of great architecture
According to Alexander, the great architectures:
• not made from rigorous, planned designs
• made of pieces custom fit to each-other and to their
environment
• aesthetics is attuned to human needs and comfort
• all involve recurring themes (called him patterns)
Patterns helped Alexander to “express design in terms of
relationship between parts of a house and the rules that transform
these relationships.” This is a holistic approach compared to a
method of building houses from predesigned modules.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.11
Examples of architectural patterns
Window on Two Sides of Every RoomThis pattern does not prescribe the size of the windows, or the
distance between them, their height from the floor, what frames
etc. The improved quality comes from the incontestable fact that a
room with two windows is better then a room with a single window.
A Place to WaitDedicated waiting (in doctor’s reception, in an airport etc) is not a
enjoyable experience (unpredictability). Solution: create a
situation which makes waiting positive — fuse in other activities
(magazines, coffee, etc), something which draws people in, not
just waiting, or, the opposite, make waiting place to draw people
into reverie, quiet, positive silence.
Alexander’s patterns have two components: utilitarian and
aesthetic. Some of the pattern names are quite poetic (Wings ofLight, Sleeping in Public), other are kind of philosophical (Zen View).
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.12
Parts and the Whole
From The Timeless Way of Building:
• Design is often thought of as a process of synthesis, a
process of putting together things, a process of combination.
• A whole is created by putting together parts. The parts come
first: and the form of the whole comes second.
• But it is impossible to form anything which has the character
of nature by adding preformed parts.
• When parts are modular and made before the whole, by
definition then, they are identical, and it is impossible for
every part to be unique, according to its position in the whole.
Patterns emphasize the rôle of relationship between the parts in
determining the nature of the whole.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.13
What is Design Pattern?
According to Alexander:
“A piece of literature that describes a design problem and a generalsolution for the problem in a particular context”“Each is a three-part rule, which expresses a relation between acertain context, a problem and a solution. The pattern is . . . at the
same time a thing, which happens to the world, and the rule which
tells us how to create that thing, and when we must create it. It is
both a process and a thing; both a description of a thing which is
alive and a description of the process which will generate that
thing” (The Timeless Way of Building).
A pattern is a conflict, its resolution and the resulting synthesis.
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.14
Alexandrian pattern template
IF
• you find yourself in { context }• for example { examples }• with { problem }• entailing { forces }
THEN
• for some { reasons }• apply { design from } and/or { rule }• to construct { solution }• leading to { new context } and { other paterns }
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.15
Pattern formal structure
• Name
• Intent
• Problem
• Context
• Forces (Participants and Collaborators)
• Solution
• Sketch (Implementation)
• Resulting context (incl. related patterns)
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.16
Alcove example
179. Alcoves. . . many large rooms are not complete unless they have smaller rooms andalcoves opening off them. . .
vvv
No homogeneous room, of homogeneous height, can serve a group of peoplewell. To give a group a chance to be together, as a group, a room must also givethem the chance to be alone, in one’s and two’s in the same space.This problem is felt most acutely in the common rooms of a house — thekitchen, the family room, the living room. In fact, it is so critical there, that thehouse can drive the family apart when it remains unsolved. . . In modern life,the main function of a family is emotional; it is a source of security and love.But these qualities will only come into existence if the members of the house arephysically able to be together as a family.This is often difficult. The various members of the family come and go atdifferent times of day; even when they are in the house, each has his ownprivate interests. . . In many houses, these interests force people to go off to theirown rooms, away from the family. This happens for two reasons. First, in anormal family room, one person can easily be disturbed by what the others aredoing. . . Second, the family room does not usually have any space where peoplecan leave things and not have them disturbed. . .
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.17
Alcove example (concl.)
To solve the problem, there must be some way in which the members of thefamily can be together, even when they are doing different things.Therefore:Make small places at the edge of any common room, usually no more than 6 feetwide and 3 to 6 feet deep and possibly much smaller. These alcoves should belarge enough for two people to sit, chat, or play and sometimes large enough tocontain a desk or table.
vvv
Give the alcove a ceiling which is markedly lower than the ceiling height in themain room. . .
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.18
The Wheel design pattern
Patterns are about re-use of design ideas: Don’t re-invent the
Wheel• Intent Need to move heavy objects over long distances efficiently
without use of machinery
• Problem Heavy things are hard or impossible to carry
• Context But we need to move lots of stuff around now that we have
people living in towns who don’t grow their own food, trade is really
important. . .
• Forces Wheel, axle, bearings, propulsion system (person or beast),
road
• Solution Build vehicles with wheels and smooth surfaces (roads) for
them to roll
• Resulting context Greatly increased capacity and speed. One
person or horse can move much more stuff by pulling a cart than by
carrying it. In the longer term, people who control roads get a lot of
power. In the really long term, more and more roads get built until
the entire planet is covered in concrete. . .
• Sketch Uh. . . shall I explain? (whoever did it was a genius, though)
• Alternatives Carry the stuff on the backs of people, or on the backs
of horses or other beasts of burden; drag it along the ground; put it
on a boat or barge
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.19
Patterns in Software
Types of Software Patterns (vis-á-vis Software Life Cycle)
• Analysis Patterns
• Design Patterns
• Implementation Patterns
• Process Patterns
• Project Planning Patterns
• Configuration Management Patterns
We will mostly discuss Design Patterns
Design Patterns • I
Alexei Khorev
Design and patterns
Designs humans do
Architectural design
Christopher Alexander
Great architecture
What is DP?
Patterns in Software
Patterns and Idioms
DPs for Software
DP Misconceptions
15.20
Abstraction Levels in Software Patterns
• Architectural Patterns (aka macro-architectures)These are templates for concrete software architectures —provide central organising concept which determines thesystem integrity. Examples:
– Dataflow batch processing, pipes and filters, process control