Informatics 122 Software Design II
description
Transcript of Informatics 122 Software Design II
![Page 1: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/1.jpg)
+
Informatics 122Software Design IILecture 3Emily Navarro
Duplication of course material for any commercial purpose without the explicit written permission of the professor is prohibited.
1
![Page 2: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/2.jpg)
+ Today’s Lecture
Designing for change
Design examples
Assignment 1 continued
2
![Page 3: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/3.jpg)
+ Purpose of Implementation Design An implementation design is a road map
understandable, unambiguous, consistent, helpful, …
An implementation design describes a path from application / interaction / architecture design to the product correct, complete, concise, verifiable, effective, …
An implementation design describes what the implementers should do elegant, partitionable, recomposable, resilient, …
An implementation design is a guide towards future change evolvable, …
3
![Page 4: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/4.jpg)
+ Emphasis: Changeability
An implementation design is a road map understandable, unambiguous, consistent, helpful, …
An implementation design describes a path from application / interaction / architecture design to the product correct, complete, concise, verifiable, effective, …
An implementation design describes what the implementers should do elegant, partitionable, recomposable, resilient, …
An implementation design is a guide towards future change evolvable, …
4
![Page 5: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/5.jpg)
+ Changeability
Subtle Requires foresight and careful balancing Understandable, unambiguous, consistent,
helpful, verifiable, partitionable, recomposable, resilient, evolvable…
![Page 6: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/6.jpg)
+ Your Brainstorming: Changeability
Reusable Upgradable Maintainable Extensible Separates concerns
(modular)
Readable Organized Simple Understandable
Secure Efficient Fast Clever Elegant
![Page 7: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/7.jpg)
+ Changability: Basic Principles Low Coupling: Reducing interdependency
Changes don’t propagate Reuse is facilitated
High Cohesion: Grouping functionality Easier to find things Metaphor guides decisions
e.g., adapter, interpreter, observer
Information Hiding
![Page 8: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/8.jpg)
+ Low Coupling/High Cohesion
…
vs.
![Page 9: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/9.jpg)
+ Information Hiding Made Very Simple A List class with:
1) getArray() : Array2) getElementAt(int i) : Object
![Page 10: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/10.jpg)
+ Information Hiding Made Very Simple A List class with:
1) getArray() : Array2) getElementAt(int i) : Object
It’s too slow, so we switch to a hash table1) Everywhere you call getArray needs changing2) Only List is changed (changes propagate exponentially)
Little things like this add up
![Page 11: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/11.jpg)
+ Why the Emphasis on Changability?
Why not just do it right the first time? Change abounds…
During coding During use Reuse for later projects
![Page 12: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/12.jpg)
+ Why is there so Much Change?
Designs
Outcomes
ok with customer feasible to build
![Page 13: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/13.jpg)
+ Why is there so Much Change?
Designs
Outcomes
Engineering
PhysicsPrinciplesExisting Examples
ok with customer feasible to build
![Page 14: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/14.jpg)
+ Why is there so Much Change?
Designs
Outcomes
Software Engineering
PhysicsPrinciplesExisting Examples
ok with customer feasible to build
![Page 15: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/15.jpg)
+ Why is there so Much Change?
Designs
Outcomes
Software Engineering
PhysicsPrinciplesExisting Examples
ok with customer feasible to build
![Page 16: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/16.jpg)
+ Why is there so Much Change?
Designs
Outcomes
Software Engineering
PhysicsPrinciplesExisting Examples
ok with customer feasible to build
![Page 17: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/17.jpg)
+ Why the Emphasis on Changability?
Change abounds… During coding During use Reuse for later projects
You usually just don’t know for sure…
![Page 18: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/18.jpg)
+ Changes During Coding
Refinement of the high level design
Dependencies reveal themselves Oh, I need to know [X]. I can’t access that data?
‘It turns out this class is HUGE’
Need to redesign as you go Can changes be made within the design?
![Page 19: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/19.jpg)
+ Changes During Use
Potential breakdowns at several levels
Customers have needs
Customers make requests
Operating environments change
![Page 20: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/20.jpg)
+ Changes During Reuse
A changing of context
…
![Page 21: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/21.jpg)
+ Change Happens
Let’s design for it
![Page 22: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/22.jpg)
+ Our Approach
Lots of examples (3 problems, many solutions, today)
Some overarching lessons
Build up an intuition
![Page 23: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/23.jpg)
+ Design Examples
1. Theseus and the Minotaur
2. Klax
3. Scrabble
![Page 24: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/24.jpg)
+ Example #1: Theseus and the Minotaur
http://www.logicmazes.com/theseus.html
![Page 25: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/25.jpg)
+ Original Theseus Design
![Page 26: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/26.jpg)
+ Original Theseus Design
What if we want to add “water” ?
![Page 27: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/27.jpg)
+ Original Theseus Design What if we want to add “water”?
?
![Page 28: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/28.jpg)
+ Original Theseus Design What if we want to add “water”?
?
How do we fix this?
![Page 29: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/29.jpg)
+ TntM: Changes
Changing the board size
Adding terrain types
Adding more monsters
Adding a second player
“Intelligent elements”
![Page 30: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/30.jpg)
+ TntM 2
![Page 31: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/31.jpg)
+ TntM 2: Object Interfaces & Inheritance
![Page 32: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/32.jpg)
+ TntM: Changes
Changing the board size
Adding terrain types
Adding more monsters
Adding a second player
“Intelligent elements”
![Page 33: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/33.jpg)
+ How far is too far?
Changing board size?
Pushable blocks?
Intelligent elements?
Physics challenges?
![Page 34: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/34.jpg)
+ TntM 2
![Page 35: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/35.jpg)
+ Aside: Three Degrees of Support
Is it a good solution?
Can they build that solution?
Can that solution be used to make other good solutions?
![Page 36: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/36.jpg)
Example: KLAX Video Game KLAX Chute
Tiles of random colors drop one cell at a time, starting at random times and locations
KLAX Palette Palette manipulated to catch tiles coming
down the Chute and to drop them into the Well
KLAX Well Horizontal, vertical and diagonal sets of
three or more consecutive tiles of the same color are removed, and any tiles above them collapse down to fill in the newly-created empty spaces
KLAX Status Points scored as sets are formed Lives lost as Well or Palette spills over
![Page 37: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/37.jpg)
+ A Good Klax Design?
![Page 38: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/38.jpg)
+ Chiron 2 Architectural Style
![Page 39: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/39.jpg)
+
C2 Klax
![Page 40: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/40.jpg)
+
Spelling Klax?
![Page 41: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/41.jpg)
+
Spelling Klax?
![Page 42: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/42.jpg)
+ Example #3: Scrabble
![Page 43: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/43.jpg)
+ Function Overload
Changes to rack?
![Page 44: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/44.jpg)
+ Class Overload
![Page 45: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/45.jpg)
+ (besides missing details)
![Page 46: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/46.jpg)
+ Is this a good design?
![Page 47: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/47.jpg)
+ Overengineered?
What change are you designing for?
More types of board objects?
Up to 100/60 different types of tiles/bonuses?
![Page 48: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/48.jpg)
+ Overengineered?
Meanwhile:
Board doesn’t actually work
Populating the tiles is likely a hassle
Tilepool vs. Player.currentTiles
Inelegance lead to problems
![Page 49: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/49.jpg)
+ A Nice Approach?
![Page 50: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/50.jpg)
+ A Nice Approach?
![Page 51: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/51.jpg)
+ Scrabble Changeability Can a design accommodate:
Changes to letter values?
Changes to bonus squares?
AI opponents?
Different dictionaries?
Different languages?
![Page 52: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/52.jpg)
+ Summary Designing for change is a matter of:
Controlling dependency Proper encapsulation Generalizing where you can
Which changes? What are the biggest change risks? What kind of program is this, essentially? Where is “the line”?
What do we know we will have? Put this in an interface
What variations on that might we see? Hide this behind the interface
![Page 53: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/53.jpg)
+ Practically:
What is the core we know will be true? What variations on that will we see?
If there’s something that needs to change: Can it be changed in one place? Does anything else need to be changed when it changes?
Can each class ignore its context?
Discipline
![Page 54: Informatics 122 Software Design II](https://reader035.fdocuments.us/reader035/viewer/2022070502/56814c67550346895db98cb5/html5/thumbnails/54.jpg)
+ Assignment #1 Continued
Now that we have talked through some examples, improve upon your design based upon what you have seen today.
On Thursday, 1/16, bring FIVE copies of your improved design One with your name and ID on it Four anonymized copies with a number on each that I will email to
you