(c) 2009 University of California, Irvine – André van der Hoek 1 March 27, 2022 – 03:32:05 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.
24
Embed
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
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
(c) 2009 University of California, Irvine – André van der Hoek 1April 18, 2023 – 20:52:20
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.
(c) 2009 University of California, Irvine – André van der Hoek 2April 18, 2023 – 20:52:20
Today’s LectureToday’s Lecture
Design patterns
(c) 2009 University of California, Irvine – André van der Hoek 3April 18, 2023 – 20:52:20
Fundamental PrinciplesFundamental Principles
Apply rigor Separate concerns
– modularize– abstract
Anticipate change Generalize Work incrementally
(c) 2009 University of California, Irvine – André van der Hoek 4April 18, 2023 – 20:52:20
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)
(c) 2009 University of California, Irvine – André van der Hoek 5April 18, 2023 – 20:52:20
A Checklist on Class DesignA Checklist on Class Design
(c) 2009 University of California, Irvine – André van der Hoek 6April 18, 2023 – 20:52:20
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– …
(c) 2009 University of California, Irvine – André van der Hoek 7April 18, 2023 – 20:52:20
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– …
(c) 2009 University of California, Irvine – André van der Hoek 8April 18, 2023 – 20:52:20
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
(c) 2009 University of California, Irvine – André van der Hoek 9April 18, 2023 – 20:52:20
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
(c) 2009 University of California, Irvine – André van der Hoek 10April 18, 2023 – 20:52:20
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
(c) 2009 University of California, Irvine – André van der Hoek 11April 18, 2023 – 20:52:20
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
(c) 2009 University of California, Irvine – André van der Hoek 12April 18, 2023 – 20:52:20
Original Catalogue of PatternsOriginal Catalogue of Patterns
Purpose
Creational Structural Behavioral
Scope
Class Abstract Method Adapter (class) InterpreterTemplate Method