Chapter1 IntroDesignPatterns and UML PDF
Chapter1 IntroDesignPatterns and UML PDF
Contents
1.1 Introduction 2
References 8
1
1.1 Introduction
This lecture discusses the Unified Modelling Language (UML). It is a visual modelling
language used for software modelling and design in the object oriented paradigm of soft-
ware development. After providing a brief history of the language, an overview of the
components of UML 2 is provided.
Software design methods have strived to provide a way to model “good” design in software.
The notion and background to Design Patterns is given, which provides a foundation for
design.
2
Figure 1: UML diagrams
3
1.2.3 Object diagrams
Object diagrams are a special type of class diagram. An object diagram depicts the state
of a system at a particular point in time. Object diagrams preserve the relationships
between objects and show the current “state” or values of the attributes of the particular
instances of the classes at a specific point in time. Figure 3 shows the state of the objects
in the class diagram that was given in Figure 2 at a specific point in time while a user
called John Doe was doing a transaction on his savings account at a specific ATM in the
Hatfield Plaza.
4
1.2.5 Activity diagrams
Activity diagrams illustrate process in terms of activities. An activity diagram is a kind
of flow chart which shows the workflow behaviour of an operation as a sequence of actions.
For example the activities while an ATM withdrawal is processed can be ‘insert card’,
‘enter PIN’, ‘check balance’, ‘eject money’, etc. Figure 5 models the activities of a cash
withdrawal process.
5
1.2.7 Communication diagrams
A communication diagram, like a sequence diagram, is a type of interaction diagram.
Communication digrams was referred to as collaboration diagrams in UML 1.x.
The main distinction between sequence and communication diagrams is that sequence
diagrams show interaction between objects over time while communication diagrams show
the depth of the interaction between objects.
In communication diagrams the objects participating in the interaction are placed in
proximity with one another to better visualise which objects are communicating directly
with one another irrespective of the order in which the messages are passed. Figure 7
shows the same interaction that is shown in Figure 6.
• Wikipedia:URL: en.wikipedia.org/wiki/Unified_Modeling_Language
6
1.3 Design Patterns
Patterns originated as an architectural concept when designing buildings. Christopher
Alexander introduced this concept in his 1977 book on architecture, urban design, and
community livability [1]. He proposed the following definition for a pattern.
Each pattern describes a problem which 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.
Design patterns in software design are no different. In software systems there are problems
that occur over and over again for which design patterns can be identified to provide
solutions to the problems. The idea of applying patterns to software was formalised by
Kent Beck, of the Agile movement, and Ward Cunnigham and presented at OOPSLA in
1987.
The idea of software design patterns was originally not well received. It only started
to gain popularity after 1994 when Gamma et al published their book of design patterns
that describes simple and elegant solutions to specific problems in object-oriented software
design [3].
The authors of the book is affectionately referred to as the “Gang of Four ” or GoF. In
the preface of the book, the GoF, states that the book neither introduces object-oriented
programming and design, nor is it an advanced reference for object-oriented programming.
They state that the book:
The 23 classical design patterns, discussed by GoF, are categorised according to their
purpose into Creational, Behavioural and Structural Patterns. A further level of categori-
sation applied has to do with the relationships between the classes. The object-oriented
concept of delegation is classified as “object” while patterns with a predominantly inher-
itance relationship structure are referred to as “class” patterns.
When writing software it is important to address the quality attributes of the solution
which includes user friendliness, effectiveness and efficiency. All patterns adresses one
or more software quality requirements. Some patterns addresses specific quality require-
ments. For example Singleton and Flyweight addresses efficiency of memory usage while
Prototype is aimed at reducing execution time.
Despite the fact that most patterns increases the execution time owing to indirection
created through excessive use of inheritance and delegation, invariably adaptability and
maintainability of the code is greatly enhanced. Software applying design patterns is
usually more robust and reliable owing to the use of tried and tested techniques. Design
patterns are very useful abstraction tools that software engineers have at their disposal
moving design decisions to a higher level of abstraction. Programmers who are competent
in using design patterns are likely to be more effective in their work.
7
1.3.1 Internet Resources
The following internet resources may be helpful and provide a very good overview of the
classic design patterns.
• Wikipedia:
References
[1] Christopher Alexander, Sara Ishikawa, and Murray Silverstein. A Pattern Language:
Towns, Buildings, Construction (Cess Center for Environmental). Oxford University
Press, later printing edition, August 1977. ISBN 0195019199.
[2] Simon Bennett, John Skelton, and Ken Lunn. Schaum’s Outline of UML. McGraw-Hill
Professional, UK, 2001. ISBN 0077096738.
[3] Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design patterns :
elements of reusable object-oriented software. Addison-Wesley, Reading, Mass, 1995.
[4] Wikipedia. Unified modeling language — wikipedia, the free encyclopedia, 2012. URL
https://en.wikipedia.org/wiki/Unified_Modeling_Language. [Online; accessed
28-July-2012].