Thursday, May 18, 2006
How many Behavior Patterns
Reference:
www.tml.tkk.fi/~pnr/GoF-models/html
State Pattern
One class changed 3 objects/ positions
Physical state changes
Someone changes his/ her behavior.
Strategy Pattern
Change strategy according to plan.
All plans one output the same
Template Method
Slightly equal to prototype (Creational)
You can modify in this area.
Visitor
Without changing the task of particular object.
The object do different tasks.
Getting into the object
Tuesday, May 16, 2006
Template Method
GoF Patterns - Template Method
Putting Patterns into Practice
For Template Method create a small hierarchy of animals with the superclass containing a skeleton method for moving from one location to another and each subclass 'filling-in' the detail of how that type of animal moves (e.g. crabs and cats will move in different ways).
Composite
GoF Patterns - Composite
Putting Patterns into Practice
Investigate the use of the Composite pattern by creating a Zebra class that creates instances of Zebra using instances of a Leg class, a Body class, a Head class and a Tail class (cf Factory Method and Abstract Factory exercise).
Visitor
GoF Patterns - Visitor
Putting Patterns into Practice
Write a small, prototype, application that uses Visitors to draw a circle. The radius of the circle should vary depending on the size of an element. For example:
the radius of a circle for a Collection of 2 objects will be 2 units
the radius of a circle for a Point 10@3 will be 13 units (ie 10+3)
and for aNumber the radius will be aNumber units
Factory Method
Creates an instance of several derived classes.
GoF Definition - Define and interface for creating an object, but let subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses.
Explanation
You can choose which object you can create
Create family of product.
To make a choice until customer come and ask.
Control Mechanism
Generalised UML Class Diagram
How behavior themselves – that’s sequence diagram. One object can
Suitable Human Diagram
Runtime – create on the situation
Otherhand. E.g. already created.
Object – real time, already created, programmer doesn’t know
Make an order them they will create it for you. That means runtime.
Example in software.
Maintainence.
Go to buy tickets
They have tickets already created.
Read Your Case Study
Create Real time object
Which creational patterns
Family of classes
Family of object/ product are created by system.
Allow the customer to choose – Factory Method.
Builder
Separate object construction from its representation.
GoF Definition – Separate the construction of a complex or more than two object from its representation so that the same construction process can create different representations.
Explanation: e.g. Burger King, Mcdonald, KFC
Kid Meal (object)
Various variability (collection of different objects)
UML class diagram
Shop
Kid meal – paying for one product – burger, fries and drink.
Partitioning Patterns – Composite
Generalisation – Abstract
Build – builder
The structure how you do you do your chair.
Prototype
Factory Method
A fully initialized instance to be copied or cloned.
GoF Definition – specify the king of objects to create using a prototypical instance, and create new objects by copying this prototype.
e.g. enrolment certificate – already there
change it according to the users.
Name
Courses
Payment
Copy that change it for necessary.
UML class diagram
Singleton
A class of which only a single instance can exist
GoF Definition – ensure a class has only one instance and provide a global point of access to it.
Explanation
Several of people can use several times as soon as you creates object.
e.g. same software can use from different companies.
UML class diagram
References:
http://www.agilemodeling.com/style/classDiagram.htm
http://www.smartdraw.com/tutorials/software-uml/uml2.htm
http://www.agilemodeling.com/artifacts/classDiagram.htm
http://www.objectmentor.com/resources/articles/umlClassDiagrams.pdf
http://pigseye.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/class.htm
http://www.developer.com/design/article.php/2206791
http://www.128.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/
http://www.builderau.com.au/program/0,39024614,39170202,00.htm
+ public
- private
# protected
These 5 symbols are important in UML Diagram.
Association
Multiplicity (Cardinality)
Composition and Aggregation
Inheritance
Interface
Why we use the Creational Patterns?
Object create on runtime.
Structural Patterns
Relating two class
Both class use different language
Translate
More than two classes how you can structure relate each other?
Bridge – two classes relate each other.
Adapter – different languages
Composite – a lots of classes and objects relate each other.
Decorator – calling the same class, use several times, decorate in one class, using that decorate the room
Façade – interface, one college have many departments, reception is interface for the college.
Flyweight – similar to Façade, so many system out there. Sharing support large number of, a lots of objects existing
Proxy – e.g. filter, firewall unnecessary info. Block, necessary info. Pass through.
One system – proxy behaviour of filter – another system
Industrial Logic – Papers - A Learning Guide To Design Patterns
Introduction
What is A Study Group?
Definition of a study Group?
Study Group vs. Lectures
Nuts & Bolts
Suggested Navigation
Design Patterns Navigation
Opening Questions
The Moderator’s Responsibility
Opening Questions For A Study Group
Using A Pattern Catalogue
“A Pattern Language” by C.Alexander et al, 1977 OUP.
Skim the attached summary of the language (5 minutes)
Read the attached description of using patterns to build a porch, looking in the catalogue for more detail about the patterns which have been used (10 minutes)
Write a paragraph describing the requirements of a small student hall of residence (5 minutes)
Thinking about the design of a small hall of residence work through Alexander’s instructions on choosing patterns (attached) using his pattern catalogue “A Pattern Language” (20 minutes)
If you have any time left have a look at “The Timeless Way of Building” by C.Alexander, 1979 OUP
PAFSD Portfolio – 2005/6
Complete 4 of the 5 tasks described below.
Task One: Designing with Patterns
Task Two: Coding with Patterns
Task Three: Patterns and Software Development
Task Four: Critiquing Patterns
Task Five: Patterns Blog
What’s this unit about?
Practical
How to use the pattern catalogue?
What’s the pattern going to be about/
Consequency – How is it consequency important?
Have I missed this chapter?
Coursework?
Have you understand the pattern?
Describing your thought.
Introduce the UML Diagram
Reference:
http://www.agilemodeling.com/essays/umlDiagrams.htm
13 Diagrams. 9 Diagrams are important in that.
3 different categories.
Structure – hold date (class, object, component)
Behavior
Interaction
Between two objects. You behave yourself. You interact with other people.
Activity Diagram - Depicts high-level business processes, including data flow, or to model the logic of complex logic within a system
Develop of Software
Customer
All the symbols have different meanings
Actor can be different positions (e.g. actor may be – human being, machine, etc.)
Class Diagram - Shows a collection of static model elements such as classes and types, their contents, and their relationships.
Communication Diagram - Shows instances of classes, their interrelationships, and the message flow between them. Communication diagrams typically focus on the structural organization of objects that send and receive messages. Formerly called a Collaboration Diagram
Object Diagram - Depicts objects and their relationships at a point in time, typically a special case of either a class diagram or a communication diagram.
Class is the collection of objects. Some class will have an object.
Sequence Diagram - Models the sequential logic, in effect the time ordering of messages between classifiers.
Start with the : and underline.
Interact with object diagram
To make sure how it works.
Component Diagram - Depicts the components that compose an application, system, or enterprise. The components, their interrelationships, interactions, and their public interfaces are depicted.
Collection of classes
Rectangle box
A sample.
Package Diagram - Shows how model elements are organized into packages as well as the dependencies between packages.
Deployment Diagram - Shows the execution architecture of systems. This includes nodes, either hardware or software execution environments, as well as the middleware connecting them.
State Diagram - Describes the states an object or interaction may be in, as well as the transitions between states. Formerly referred to as a state diagram, state chart diagram, or a state-transition diagram.
One object is changed.
Good to understand how
GoF – Design Patterns
Creational Patterns
What is the pattern?
Problem
Solution
Consequence is very important
Each phase – design, implementation, testing
Think about can create one object?
Create an object a runtime within the class. Controlling mechanism for large number of objects you can create
Program doesn’t need to create.
How to create one object?
5 different recurring problems to create
Creational design patterns abstract the instantiation process
They help make a system independent to how its object are created, composed, and represent.
e.g. Storage – hardware
all the programs in there, but you want to work with computer
real time memory
Hard disk like warehouse.
A class creational pattern uses inheritance to vary the class that’s instantiated, whereas an object creational pattern will delegate instantiation to another object.
Whatever I want, I can open it.
The program doesn’t know what I want.
Two types of objects
This program must be creator
The user is creator object
Student come for enrolment
Abstract factory
Creates an objects of several families of classes.
Example
Abstract mean very common general
Abstract – Human
Subclass - Students
GoF Definition
Provide an interface for creating of related or dependent objects without specifying their concrete classes.
Generalised UML class diagram

References:
http://www.dofactory.com/Patterns/PatternAbstract.aspx
http://www.patterndepot.com/put/8/DesignJava.PDF
The Abstract Factory Method – provides an interface to create and return one of several families of related objects
Control Mechanism and Product is separated.
Case Study: Design Patterns
Plan too much, plan ahead, or don’t plan at all?
Development of software systems can suffer from;
Analysis paralysis: attempt to consider all possible changes in the future
Tooo design: there is tremendous pressure to deliver, not quality.
Fast Implementation: developers jump to code too quickly..
Solution to the above problem
Analysis re-use
Don’t reinvent to wheel
Requires a precise understanding of common, recurring requirement
Leverage previous work
Design re-use
Don’t reinvent to wheel
Requires a precise understanding of common, recurring design
Leverage previous work
Code re-use
Don’t relevant the wheel
Requires clean, elegant, understandable, general,
Stable code
Leverage previous work
Patterns as the solution
The concept of patterns, of which there are several different types:
Analysis Pattern – conceptual model
Design Pattern – implementation model
Architectural Pattern – system architecture.
Idiom Pattern – specific to a programming language
Principles of Good Design
Program to interface, not an implementation
Use interfaces rather than concrete classes.
Clients remain unaware of the classes of objects they use – they do adhere to the interface
This reduces implementation dependencies between subsystems.
Then use interface names, not class names.
What is variable in the design?
Consider what is variable in your design
Instead of focusing in what might force a change to your design.
Consider what you might want to change.
Two major Design Principle in Object-Oriented Paradigm
Goals
Principles
Techniques
Inheritance & Polymorphism – Modularity, Reusability
Class & Objects – Abstraction, Robustness
Interfaces & Typing – Encapsulation, Adaptablity
Why model?
To help understand the problem
To help communication of the problem.
What is a Design Pattern?
Abstract a recurring design structure
Comprises class and/ or object
Dependencies
Structure
Interactions or
conventions
Design Patterns – Why?
Designing OO software is hard
Designing reusable OO software – harder
Expert designer know not to solve every problem from first principles
They reuse solutions.
GoF Design Pattern
Scope
Purpose
Creational
Structural
Behavioural
Class
Factory Method
Adaptor (class)
Interpreter
Template Method
Object
Abstract Factory
Builder
Prototype
Singleton
Adaptor (object)
Bridge
Composite
Decorator
Flyweight
Façade
Proxy
Chain of responsibility
Command
Iterator
Mediator
Memento
Observer
State
Strategy
Visitor
11:46 a.m.
Patterns are not business objects, frameworks, algorithms, components, libraries, packages, .
Pattern is the reusable design concept.
Patterns & Algorithm
Gang of Six (GoS)
Patterns – You have to design first
Def. Of Patterns: General/ Solution to a recurring problem explained in a specific context.
Problem
Solution
Context
You can use any language your presentation.
Def. Of Algorithm: is any set of detailed instructions which results in a predictable end-state from a known beginning.
In patterns established set of rules captured.
Compare/ Differences: Overtime by experience software designers while algorithms are snippet of code which
Patterns
Typically concerned with broader architectural issues that have larger scale effects
May use algorithms
Algorithms
Solve more fine-grained computational computing (e.g. sorting, searching)
More deterministic
Have less variation among implementation strategies and tactics.
Patterns and Software: Essential Concepts and Terminology by Brand Appleton
Cont’d
Algorithm tends to be more in-depth than pattern because they mostly address issues of computational complexity and not so much the underlying the issues of the people who are both using and building the software. On the other hands patterns fundamentally address people issues (like maintainability) more so than simple hardware & software efficiency memory issues.
Alexander’s word …
Def. of patterns.
Why are we comparing of these?
Reusability is a common.
12:15 p.m.
Patterns and Components
Patterns can implement – small talk, C++, Java (programming language)
Components
A small binary object or program that perform a specific function and designed in such a way that.
No context specific
Can be implemented in any programming language.
e.g. look at the chair
Make up separately.
How interface? – components may be component made by wood.
Problem with the chair – stiff/ flexible/ relax
Solution – soften
12:41 p.m.
Patterns vs. Business Objects
Are modeled after a business concept e.g. person, place event or process.
Also represent real world things e.g. employees.
They are also objects in computer programs which
They are also used to solve business object problem.
Reuse the business object or software.
Component can use any language
Is a partly of software.
Can’t change anything
Business object is an object to build for a singular, particular software.
Patterns
Suggestive
Requires implementations and usually change
Used for rationale behind the model or code
User molds it to fit their requirements
Has little effect on systems integration
Business Objects
Perscriptive
Used as is
Used for its model or code
User molds to its requirements
Helps with integration of systems
Analysis Patterns and Business Objects by Martin Fowler
14:00 p.m.
Patterns vs. Frameworks
A set of cooperating classes that make up a reusable design for specific class of software e.g. business applications, .
Framework exhibit inversion of control at runtime.
-.NET is a product.
Type of pattern.
Software architecture and design.
Together patterns and frameworks
Help to improve software quality and reduce development time e.g. through reuse, extensibility, modularity and performance
Using that you can build complete software. That is a framework.
You can be created patterns within the framework.
Can Patterns be created within the framework?
e.g. .Net application – you can use .net pattern
A pattern is ‘the abstraction from a concrete form which keeps recurring in specific non-arbitrary contexts’.
Patterns support the reuse of software architectures and mechanistic design.
Patterns capture the static and dynamic structures of successful solutions to problems that arise in a particular domain.
A framework is a set of cooperating classes that make up a reusable design for a specific class of software. Frameworks support the reuse of detailed design and code.
Patterns
Represents knowledge and experience about software
Logical in nature
Need to be implemented each time they are used
Less specialized
Smaller architectural elements
Frameworks
Executable software
Physical in nature
Can be reused
More specialized
Implementation of a system of design patterns
Patterns and Software: Essential Concepts and Terminology by Brad Appleton
Library is a collection of particular class.
You can call particular class.
Package is a similar to framework.
Library – package – framework.
Library is a piece of routine.
Problem – solution
What types of problem to choose a particular solution/ class.
To solve this problem.
Patterns vs. Packages
Microsoft word – is a software package
Patterns - Same problem in a context.
Recurring problem
Identify solution
Context
Consequences
Patterns – identify to software.
Patterns
Is a concept
The concept can be used in any programming language
Patterns are used in the design phase of the software development life cycle.
It as easy for a novice adopt to patterns.
It can be modified
Patterns can be compared to a template as its an outline of best way to solve a problem its generic written and needs (modification) to suit the programming language
Packages
A piece of software
Packages are normally in a specific programming language
You would have to be knowledgeable in
Cannot be modified
Packages are used in the coding phase in the development life cycle.
9:30 – 10:46
Unit Descriptions
Aims, Learning Outcomes
Syllabus Outline
Teaching and Learning Strategy
Student-centred Learning
Group discussion
Personal research
Extensive reading
Assessment
Credit Points 10
100% coursework (no exam)
Both individual and group work
Assessing both theory and practical skills.
Reading
Course material and recommended reading
http://www.tech.port.ac.uk/staffweb/chandlej/PAFSD.html
A blog for this unit can be found
http://pafsd.blogspot.com/
(4) Courseworks
-
-
criticize,
What do you think about it? You have to explain. Why?
How do you go to learn Java?
You must be happy you learn yourself
Somebody help you?
I’m going to teach you
11:00 – 13:00
Introduction to Patterns
Pattern – a introduction
Patterns in Software Engineering
Comparison with other reusable tools
Types of patterns
Christopher Alexander
All buildings are the results of applying sets of rules. When this expertise fails to be passed on, bad buildings and broken communities result.
Result of this is birth of ‘the concept of Patterns
Alexander codified best building practice by mean of 253 individual but related Patterns
Alexander’s word
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”
Pattern Language.
Towns/ Buildings/ Construction, 1977 New York Oxford University Press.
Data Structure
Reusable concepts
J2EE
Pattern is a concept
A project/ problem should be document
They don’t need to break their head
Pattern in Real Life ‘an analogy to Pattern.
Context: You are a student living at Waterloo, London and need to get to CBAD lecture at St.Patricks College London, in less than an hour. RMT Union announce strike – only limit tube services are available. Travelling by bus would take too long because of traffic jams and you don’t have access to a bike. You only have a limited amount of money and need to buy much, pay some library fines and get home some how. You could take a taxi, but that costs …
Problem: How do you get to class on time?
Solution: Walk to college
Consequences: Living within your financial, temporal and physical limits you can get to class.
Example/ known use: It might take 20 minutes to walk to Oxford Street.
Related Patterns: Avoid Library Fine and Lunch to catch Black Taxi, Buy a Bike.
Pattern in plain English
Patterns are found in real systems, as well-tried solutions to real problems.
A Pattern is a formalized instruction that says;
“if you encounter this problem then solve it like that”
Patterns help to:
Reduce the need for redesign
Produce reusable design problems.
Acts as templates
Pass on knowledge from experts to novices.
Patterns support the modularity. So that changes can be made internally …
Why use patterns?
Instead of re-inventing the wheel for any project, capitatise an existing work and deploy it
Benefits:
Reduced maintenance costs as one improvement will improve all projects
Improved quality because of through testing in a variety of situations
They help through learning by example.
Pass knowledge on from expert to novice
Magic words reuse.
What patterns are not
Untested theories
Solutions that have worked only once
Applicable to every context
The answer to every software design problem
How to preserve the patterns?
Element of components of Patterns can be used to document the newly identified patterns.
Which can be called as pattern catalogue.
Element of Patterns
Name
Problem
Context
Forces
Solution
Examples
Resulting Context
Rationale
Related Patterns
Known uses
Recommended reading book:
This book contains 23 patterns, each with a solution for a recurring problem faced in object-oriented design.
Gamma, E., Helm, R., Johnson R. and Vlissides, J., Design Patterns: Elements of Reusable Object-oriented Software, Addison Wesley, 1994, 02 0163 3612, Y
14:00 – 15:00
Patterns in Software Engineering
Patterns in Software Development
Software Engineering adapt the Pattern concept from construction Engineering.
It is the New Paradigm in Software Development
Entity Modelling
Object Oriented Modelling
Pattern Oriented Modelling
New systems analysis and design technique for reuse software architecture and design
Pattern represent solutions to problems that arise when developing software within a particular context.
“Pattern = (Problem + Solution) in a context”
How Pattern can be apply?
Gamma’s definition: “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context”
A object-oriented design pattern systematically names, explains and evaluates an important and recurring design in object-oriented systems.
Why use patterns in Software Design?
These patterns make OO Design more flexible, elegant, and ultimately reusable.
Pattern capture the static and dynamic structures and collaborations of successful solutions to problems that arise when building applications a particular domain
Patterns help to improve key software quality. Factors such as reuse, extensibility, modularity, performances.
Types of Software Patterns
Architectural Patterns
Design Patterns
Idioms
Other types of Patterns in Software Industry
Process
Analysis Patterns
Protocols Patterns
Data Structure Patterns
Algorithmic Patterns
Cognitive Patterns
Organisational Patterns
Origin of Software Patterns
Christopher Alexander
Several books
Gang of Four (GoF)
Design Patterns: Elements of reusable.
Gang of Five (GoV)
…
Conferences on Patterns languages of Program Design (PLoP or PLoPD)
GoF and GoV
…
No Confusion
Patterns are not
Business objects
Frameworks
Algorithms
Components
Libraries
Packages
Patterns is the reusable design concept.
15:30 – 17:00
Group Discussion: Differences/ Compare between Design Patterns and Java Packages
Group No.(6)
http://groups.yahoo.com/group/group-discussion/
Email: group-discussion@yahoogroups.com
Lorraine Scbata
Sipiwe Magoche
Manyozo Phiri
Basco Abor
Frederick Abayeta
Kwame Ako – Aboagye
Nu Lwin Soe
Packages
Class
Many Classes
Collection of Program
Patterns
We use in design
Concept
Implementation & Coding State