+ All Categories
Home > Documents > (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05...

(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05...

Date post: 21-Dec-2015
Category:
View: 215 times
Download: 2 times
Share this document with a friend
Popular Tags:
27
(c) 2010 University of California, Irvine – André van der Hoek 1 January 1, 2022 – 15:05:36 Informatics 122 Software Design II Lecture 8 André van der Hoek Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.
Transcript
Page 1: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 1April 18, 2023 – 22:10:54

Informatics 122Software Design II

Informatics 122Software Design II

Lecture 8André van der Hoek

Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.

Page 2: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 2April 18, 2023 – 22:10:54

Today’s LectureToday’s Lecture

Design patterns

Assignment 4

Page 3: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 3April 18, 2023 – 22:10:54

Fundamental PrinciplesFundamental Principles

Apply rigor Separate concerns

– modularize– abstract

Anticipate change Generalize Work incrementally

Page 4: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 4April 18, 2023 – 22:10:54

A Checklist on Overall DesignA Checklist on Overall Design

Strive for grouping related functionality (high cohesion) Strive for ungrouping semi-related functionality (high

cohesion) Strive for reducing interdependency (low coupling)

Page 5: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 5April 18, 2023 – 22:10:54

A Checklist on Class DesignA Checklist on Class Design

Cohesion Completeness Convenience Clarity Consistency

Page 6: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 6April 18, 2023 – 22:10:54

A Checklist on Principles and StrategiesA Checklist on Principles and Strategies

Principles– keep it simple, stupid! (KISS)– information hiding– acyclic dependencies– …

Strategies– program to the interface– refactor– apply software patterns– use aspects– …

Page 7: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 7April 18, 2023 – 22:10:54

A Checklist on Principles and StrategiesA Checklist on Principles and Strategies

Principles– keep it simple, stupid! (KISS)– information hiding– acyclic dependencies– …

Strategies– program to the interface– refactor– apply software patterns– use aspects– …

Page 8: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 8April 18, 2023 – 22:10:54

Design PatternsDesign Patterns

“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” [Alexander, Ishikawa, Silverstein 1977]

Pattern– name– problem– solution– consequences

Page 9: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 9April 18, 2023 – 22:10:54

Software Design PatternsSoftware Design Patterns

“Descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context” [Gamma, Helm, Johnson, Vlissides 1995]

Pattern– name and classification– intent– also known as– motivation– applicability– structure– participants– collaborations– consequences– implementation– sample code– known uses– related patterns

Page 10: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 10April 18, 2023 – 22:10:54

Patterns Are Designed to Avoid RedesignPatterns Are Designed to Avoid Redesign

Creating an object by specifying a class explicitly Dependence on specific operations Dependence on hardware and software platform Dependence on object representations or

implementations Algorithmic dependencies Tight coupling Extending functionality by subclassing Inability to alter classes conveniently

Page 11: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 11April 18, 2023 – 22:10:54

Patterns Apply Two Design PrinciplesPatterns Apply Two Design Principles

Program to an interface, not an implementation– interface should be separately defined, using abstract

classes Favor object composition over inheritance

Page 12: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 12April 18, 2023 – 22:10:54

Original Catalogue of PatternsOriginal Catalogue of Patterns

Purpose

Creational Structural Behavioral

Scope

Class Abstract Method Adapter (class) InterpreterTemplate Method

Object

Abstract FactoryBuilderPrototypeSingleton

Adapter (object)BridgeCompositeDecoratorFaçadeFlyweightProxy

Chain of ResponsibilityCommandIteratorMediatorMementoObserverStateStrategyVisitor

Page 13: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 13April 18, 2023 – 22:10:54

Abstract Method (Creational, Class)Abstract Method (Creational, Class)

Page 14: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 14April 18, 2023 – 22:10:55

Abstract Factory (Creational, Object)Abstract Factory (Creational, Object)

Page 15: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 15April 18, 2023 – 22:10:55

Builder (Creational, Object)Builder (Creational, Object)

Page 16: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 16April 18, 2023 – 22:10:55

Adaptor (Structural, Object)Adaptor (Structural, Object)

Page 17: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 17April 18, 2023 – 22:10:55

Composite (Structural, Object)Composite (Structural, Object)

Page 18: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 18April 18, 2023 – 22:10:55

Decorator (Structural, Object)Decorator (Structural, Object)

Page 19: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 19April 18, 2023 – 22:10:55

Proxy (Structural, Object)Proxy (Structural, Object)

Page 20: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 20April 18, 2023 – 22:10:55

Command (Behavioral, Object)Command (Behavioral, Object)

Page 21: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 21April 18, 2023 – 22:10:55

Observer (Behavioral, Object)Observer (Behavioral, Object)

Page 22: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 22April 18, 2023 – 22:10:55

State (Behavioral, Object)State (Behavioral, Object)

Page 23: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 23April 18, 2023 – 22:10:55

Visitor (Behavioral, Object)Visitor (Behavioral, Object)

Page 24: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

(c) 2010 University of California, Irvine – André van der Hoek 24April 18, 2023 – 22:10:55

More…More…

Patterns– http://en.wikipedia.org/wiki/Software_pattern– http://c2.com/ppr/

Interaction design patterns– http://en.wikipedia.org/wiki/Interaction_design_pattern

Anti-Patterns– http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-

patterns

Refactoring– http://en.wikipedia.org/wiki/Refactoring

And numerous, numerous, numerous books

Page 25: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

© 2010 University of California, Irvine – André van der Hoek 25February 8, 2010 – 21:49:30

Assignment 4 – Design Patterns

Improve the design of Calico by replacing existing structures in the UML model with appropriate patterns– start with any of the designs available to your group

You should apply at least 7 different design patterns– at least three not discussed in class

Each use of a pattern should be carefully motivated in a brief accompanying document

Page 26: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

© 2010 University of California, Irvine – André van der Hoek 26February 8, 2010 – 21:49:30

Assignment 4 – Design Patterns

Each group must turn in:– the original UML diagram from which you started– a new UML diagram, with each pattern precisely highlighted as

to where it resides in the UML diagram– a document describing

the motivation for each pattern the impact the application of the pattern has on the original design

(i.e., how far reaching is the change to incorporate the pattern?)– graded on usefulness of the pattern, diversity of patterns,

rationale, and level of design understanding

Each person also needs to submit a team evaluation (new forms available on class webpage)

Printed copy due Tuesday, February 16th at the beginning of class

Page 27: (c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.

© 2010 University of California, Irvine – André van der Hoek 27February 8, 2010 – 21:49:30

Further Tips

Read the book

Discuss the patterns with each other

Imagine possible changes against which you would like to insulate

Try different parts of the code

Use the UML


Recommended