Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring...
Transcript of Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring...
![Page 2: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/2.jpg)
What is design?
● Not referring to UX (even though it’s important)
![Page 3: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/3.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:
![Page 4: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/4.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
Audio
Input
Network Persistence
Graphics
ClientLogic
ServerLogic
![Page 5: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/5.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
Audio
Input
Network Persistence
Graphics
ClientLogic
ServerLogic
![Page 6: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/6.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact ?
![Page 7: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/7.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact architecture
![Page 8: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/8.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
– The interfaces & abstractions they expose (or hide!)
![Page 9: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/9.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
– The interfaces & abstractions they expose (or hide!)
What is an abstraction?
![Page 10: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/10.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
– The interfaces & abstractions they expose (or hide!)
Server server{port};while (true) { auto incoming = server.receive(); ... server.send(outgoing);}
What does the networking librarythat I gave to you expose/hide?
![Page 11: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/11.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
– The interfaces & abstractions they expose (or hide!)
Is design UML?
![Page 12: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/12.jpg)
What is design?
● Not referring to UX (even though it’s important)
● Includes many things:– The components of the system
– How they interact
– The interfaces & abstractions they expose (or hide!)
Is design UML?
Is UML design?
![Page 13: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/13.jpg)
Why does design matter?
![Page 14: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/14.jpg)
Why does design matter?
● Translating requirements and stories to code
As a XI can YSo that ZAs a X
I can YSo that ZAs a X
I can YSo that ZAs a X
I can YSo that ZAs a X
I can YSo that Z
PerformanceAvailability
Security...
Design
/////////////////////////////////////////////////////////////////////////////// Single Threaded Networking//// This file is distributed under the MIT License. See the LICENSE file// for details./////////////////////////////////////////////////////////////////////////////
#include <unistd.h>#include "ChatWindow.h"#include "Client.h"
intmain(int argc, char* argv[]) { if (argc < 3) { printf("Usage:\n%s <ip address> <port>\ne.g. %s localhost 4002\n", argv[0], argv[0]); return 1; }
networking::Client client{argv[1], argv[2]};
bool done = false; auto onTextEntry = [&done, &client] (std::string text) { if ("exit" == text || "quit" == text) { done = true; } else { client.send(text); } };
ChatWindow chatWindow(onTextEntry); while (!done && !client.isDisconnected()) { try { client.update(); } catch (std::exception& e) { chatWindow.displayText("Exception from Client update:"); chatWindow.displayText(e.what()); done = true; }
auto response = client.receive(); if (!response.empty()) { chatWindow.displayText(response); } chatWindow.update(); }
return 0;}
![Page 15: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/15.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
![Page 16: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/16.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
How much time do professionalprogrammers spend reading code?
![Page 17: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/17.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
![Page 18: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/18.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
![Page 19: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/19.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
● Determines ease & risk for change.
![Page 20: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/20.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
● Determines ease & risk for change.– Understanding of requirements will change
![Page 21: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/21.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
● Determines ease & risk for change.– Understanding of requirements will change
– Requirements will change
![Page 22: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/22.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
● Determines ease & risk for change.– Understanding of requirements will change
– Requirements will change
– Your code may outlast your time at a company
![Page 23: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/23.jpg)
Why does design matter?
● Translating requirements and stories to code
● Understandability
● Performance & reliability
● Reusability
● Determines ease & risk for change.– Understanding of requirements will change
– Requirements will change
– Your code may outlast your time at a company
● Once software is too complex to reason about,it is too late
![Page 24: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/24.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
![Page 25: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/25.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
● Common attributes of a bad design: [Ousterhout 2018]
![Page 26: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/26.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
● Common attributes of a bad design: [Ousterhout 2018]
– Change AmplificationAn apparently simple change requires modifying many locations
![Page 27: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/27.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
● Common attributes of a bad design: [Ousterhout 2018]
– Change AmplificationAn apparently simple change requires modifying many locations
– Cognitive LoadThe developer needs to know a great deal in order to complete a task
![Page 28: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/28.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
● Common attributes of a bad design: [Ousterhout 2018]
– Change AmplificationAn apparently simple change requires modifying many locations
– Cognitive LoadThe developer needs to know a great deal in order to complete a task
– Unknown unknownsPotions of code to modify for a task may be hard to identify
![Page 29: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/29.jpg)
What makes a design bad?
● Too many possible ways to design poorly to list
● Common attributes of a bad design: [Ousterhout 2018]
– Change AmplificationAn apparently simple change requires modifying many locations
– Cognitive LoadThe developer needs to know a great deal in order to complete a task
– Unknown unknownsPotions of code to modify for a task may be hard to identify
These are symptoms of complexity.
![Page 30: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/30.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
![Page 31: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/31.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
![Page 32: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/32.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
hide
![Page 33: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/33.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
minimize
hide
![Page 34: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/34.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
● What is complexity?
![Page 35: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/35.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
● What is complexity?– No agreed upon universal definition; many variants
![Page 36: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/36.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
● What is complexity?– No agreed upon universal definition; many variants
– Grows as entities/concepts in project are connected/woven together
![Page 37: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/37.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
● What is complexity?– No agreed upon universal definition; many variants
– Grows as entities/concepts in project are connected/woven together
[Watch “Simple Made Easy” for one interesting perspective]
![Page 38: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/38.jpg)
What makes a design good?
● It identifies & manages complexity– Inherent (essential) complexity
– Incidental (accidental) complexity
● What is complexity?– No agreed upon universal definition; many variants
– Grows as entities/concepts in project are connected/woven together
[Watch “Simple Made Easy” for one interesting perspective]– One other heuristic is risk of change
![Page 39: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/39.jpg)
What makes a design good?
Broadly
● Divides the system into independent components
![Page 40: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/40.jpg)
What makes a design good?
Broadly
● Divides the system into independent components
● Makes it easy for developers to get their jobs done
![Page 41: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/41.jpg)
What makes a design good?
● Not clever
![Page 42: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/42.jpg)
What makes a design good?
● Not clever!
int x = foo(bar(baz(bam(a), b), c), d);
![Page 43: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/43.jpg)
What makes a design good?
● Not clever!!
// this subroutine is called thousands of times.// use longjmp instead of loops to increase speed.
voidcalculate(struct salesinfo* sales){ jmp_buf buffer; int i=setjmp(buffer); if (!(i<sales->count)) RETURN_NOTHING; addvaluetosubtotal(sales->values[i]); if (i<sales->count) longjmp(buffer,i+1);}
int x = foo(bar(baz(bam(a), b), c), d);
http://thedailywtf.com/articles/Longjmp--FOR-SPEED!!!
![Page 44: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/44.jpg)
What makes a design good?
● Not clever!!!
// this subroutine is called thousands of times.// use longjmp instead of loops to increase speed.
voidcalculate(struct salesinfo* sales){ jmp_buf buffer; int i=setjmp(buffer); if (!(i<sales->count)) RETURN_NOTHING; addvaluetosubtotal(sales->values[i]); if (i<sales->count) longjmp(buffer,i+1);}
int x = foo(bar(baz(bam(a), b), c), d);
http://thedailywtf.com/articles/Longjmp--FOR-SPEED!!!
![Page 45: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/45.jpg)
What makes a design good?
● Not clever
● Loose coupling
vs
![Page 46: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/46.jpg)
What makes a design good?
● Not clever
● Loose coupling
vs
Why?
![Page 47: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/47.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)
![Page 48: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/48.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)
...goto yourcode... ...
yourcode:...
![Page 49: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/49.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
![Page 50: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/50.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
int global = ...
global = ...
int global = ...
global = ...
... = global
... = global
![Page 51: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/51.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
int global = ...
global = ...
int global = ...
global = ...
... = global
... = global
![Page 52: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/52.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
int global = ...
global = ...
int global = ...
global = ...
... = global
... = globalSingletons have these constraints and worse.
![Page 53: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/53.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
We will spend a day in the future on this.
![Page 54: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/54.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
![Page 55: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/55.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
Cat cat = new Cat;...delete cat;
![Page 56: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/56.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
Cat cat = new Cat;...delete cat;
Process p;p.doStep1();p.doStep2();p.doStep3();
![Page 57: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/57.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
Cat cat = new Cat;...delete cat;
Process p;p.doStep1();p.doStep2();p.doStep3();
This is more insidious!
Process p;p.foo();p.bar();p.baz();
![Page 58: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/58.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
– Passing data to/from each other
![Page 59: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/59.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
– Passing data to/from each other
x = foo(1,2)def foo(a, b): ...
![Page 60: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/60.jpg)
What makes a design good?
● Not clever
● Loose coupling
– Content (accessing implementation of another component)– Common global data
– Subclassing
– Temporal
– Passing data to/from each other
– Independence
![Page 61: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/61.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
foo()
bar() baz()
vsfoo()
bar()
![Page 62: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/62.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
foo()
bar() baz()
vsfoo()
bar()
Do you agree?Why?
![Page 63: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/63.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
![Page 64: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/64.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
& a consistent, self contained view per level
![Page 65: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/65.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
New / GreenfieldCode
Wrapper API
Legacy / Sketchy Code
![Page 66: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/66.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
New / GreenfieldCode
Wrapper API
External Library
![Page 67: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/67.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
New / GreenfieldCode
Wrapper API
External Library
What impact does this have oninvariants & types?
![Page 68: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/68.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
● Cohesion
● ...
vs
![Page 69: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/69.jpg)
What makes a design good?
● Not clever
● Loose coupling
● High fan in / low fan out
● Layers / Stratification
● Cohesion
● ...
But these are the ends, not the means
![Page 70: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/70.jpg)
Revisiting Complexity
● We can characterize causes of complex designs [Ousterhout 2018]
![Page 71: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/71.jpg)
Revisiting Complexity
● We can characterize causes of complex designs [Ousterhout 2018]
– DependenciesCode cannot be understood in isolation because of relationships to other code.
![Page 72: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/72.jpg)
Revisiting Complexity
● We can characterize causes of complex designs [Ousterhout 2018]
– DependenciesCode cannot be understood in isolation because of relationships to other code.
– ObscurityImportant information about code is not obvious.
![Page 73: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/73.jpg)
Revisiting Complexity
● We can characterize causes of complex designs [Ousterhout 2018]
– DependenciesCode cannot be understood in isolation because of relationships to other code.
– ObscurityImportant information about code is not obvious.
These directly relate to thequalities of good code we just saw.
![Page 74: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/74.jpg)
Consider a design
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
![Page 75: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/75.jpg)
Consider a design
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
Is this simple? Why?
![Page 76: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/76.jpg)
Consider a design
● What if you want to modify the business logic?
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
![Page 77: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/77.jpg)
Consider a design
● What if you want to modify the business logic?
● What if you want to reuse the business logic?
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
![Page 78: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/78.jpg)
Consider a design
● What if you want to modify the business logic?
● What if you want to reuse the business logic?
● What if you want to replace the display?
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
![Page 79: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/79.jpg)
Consider a design
● What if you want to modify the business logic?
● What if you want to reuse the business logic?
● What if you want to replace the display?
UserInterface Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
Like a basket woven together,you get everything or nothing.
![Page 80: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/80.jpg)
Consider a design
Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
UserInterface
![Page 81: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/81.jpg)
Consider a design
Is this simpler? Why?
Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
UserInterface
![Page 82: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/82.jpg)
Consider a design
What is still complex? Why?Is this simpler? Why?
Graphics
DataStorage
BusinessLogic
EnterpriseBackbone
UserInterface
![Page 83: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/83.jpg)
Consider a design
● The fewer connected or conflated concepts, the better
![Page 84: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/84.jpg)
Consider a functionboolisFasterThanSound(double speed) { return speed > MACH1;}
![Page 85: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/85.jpg)
Consider a functionboolisFasterThanSound(double speed) { return speed > MACH1;}
Is this simple or complex? Why?
![Page 86: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/86.jpg)
boolisFasterThanSound(double speed) { return speed > MACH1;}
(double speed, double angle) {
}
Consider a function
Is this simple or complex? Why?
![Page 87: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/87.jpg)
Consider a functionboolisFasterThanSound(double speed) { return speed > MACH1;}
A good design should be hard to misuse
(double speed, double angle) {
}Is this simple or complex? Why?
![Page 88: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/88.jpg)
Consider a classclass Student {public: ... ID getID() const; Name getName() const; Address getAddress() const;
void storeToDatabase() const; static Student readFromDatabase();
bool canApplyForCoOp(); bool meetsDegreeRequirements();};
![Page 89: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/89.jpg)
Consider a classclass Student {public: ... ID getID() const; Name getName() const; Address getAddress() const;
void storeToDatabase() const; static Student readFromDatabase();
bool canApplyForCoOp(); bool meetsDegreeRequirements();};What is good about this class?
![Page 90: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/90.jpg)
Consider a classclass Student {public: ... ID getID() const; Name getName() const; Address getAddress() const;
void storeToDatabase() const; static Student readFromDatabase();
bool canApplyForCoOp(); bool meetsDegreeRequirements();};What is good about this class? What is bad about this class?
![Page 91: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/91.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
![Page 92: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/92.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
Be careful.This can be a good place to start,
but a poor place to end.
![Page 93: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/93.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
![Page 94: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/94.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
This is the Code Complete definition,not a universal one!
![Page 95: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/95.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
Deeply tied to information hiding
![Page 96: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/96.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
● Consistency
![Page 97: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/97.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
● Consistency
● Inheritance?
![Page 98: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/98.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
● Consistency
● Inheritance?– In small, constrained doses
– Ideally through interfaces
![Page 99: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/99.jpg)
What are our simplifying tools?
● Metaphors – identify “real world” objects & relations
● Abstraction – use high level concepts
● Encapsulation – hide the details
● Consistency
● Inheritance?– In small, constrained doses
– Ideally through interfaces
Use especially for:1) likely/risky to change code2) frequently used code
![Page 100: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/100.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
class Student {public: ... int getID() const; ...};
![Page 101: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/101.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
class Student {public: ... int getID() const; ...};
![Page 102: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/102.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
● Separate them structurally
class Student {public: ... int getID() const; ...};
![Page 103: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/103.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
● Separate them structurally
class Student {public: ... ID getID() const; ...};
class Student {public: ... int getID() const; ...};
![Page 104: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/104.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
● Separate them structurally
● Isolate their impact through interfaces
![Page 105: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/105.jpg)
Key Strategy: Mitigate change
● Identify potential areas of change
● Separate them structurally
● Isolate their impact through interfaces
class IDCreator {public: ... virtual ID createID() = 0; ...};
![Page 106: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/106.jpg)
Key Strategy: Mitigate change
... ID studentID = student.getID(); ...
How might this hinder change?
![Page 107: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/107.jpg)
Key Strategy: Mitigate change
... ID studentID = student.getID(); ...
How might this hinder change?
How can it be resolved?
![Page 108: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/108.jpg)
Key Strategy: Mitigate change
... ID studentID = student.getID(); ...
How might this hinder change?
How can it be resolved?
What are the trade offs?
![Page 109: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/109.jpg)
Constant Vigilance
● Avoiding complexity requires a planned process
![Page 110: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/110.jpg)
Constant Vigilance
● Avoiding complexity requires a planned process– Code review everything
[metaphors, abstraction, encapsulation, consistency, inheritance]
![Page 111: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/111.jpg)
Constant Vigilance
● Avoiding complexity requires a planned process– Code review everything
[metaphors, abstraction, encapsulation, consistency, inheritance]– Write tests (simple code is easier to test)
![Page 112: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/112.jpg)
Constant Vigilance
● Avoiding complexity requires a planned process– Code review everything
[metaphors, abstraction, encapsulation, consistency, inheritance]– Write tests (simple code is easier to test)
● Know when & where you make bad decisions
– technical debt
![Page 113: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/113.jpg)
Constant Vigilance
● Avoiding complexity requires a planned process– Code review everything
[metaphors, abstraction, encapsulation, consistency, inheritance]– Write tests (simple code is easier to test)
● Know when & where you make bad decisions
– technical debt● You end up paying it back!
![Page 114: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/114.jpg)
Design Smells
● A design smell is a clue that better design is needed
![Page 115: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/115.jpg)
Design Smells
● A design smell is a clue that better design is needed
● Such as: (adapted from John Ousterhout)
– Thin components● Is it really hiding an implementation?● Is complexity arising from having to many small classes?
![Page 116: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/116.jpg)
Design Smells
● A design smell is a clue that better design is needed
● Such as: (adapted from John Ousterhout)
– Thin components● Is it really hiding an implementation?● Is complexity arising from having to many small classes?
– Information leaks● Can I see the implementation details? (unintentional interface)● Repeated similar code
![Page 117: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/117.jpg)
Design Smells
● A design smell is a clue that better design is needed
● Such as: (adapted from John Ousterhout)
– Thin components● Is it really hiding an implementation?● Is complexity arising from having to many small classes?
– Information leaks● Can I see the implementation details? (unintentional interface)● Repeated similar code
– Difficulty making a change
![Page 118: Design - Simon Fraser Universitywsumner/teaching/373/03-design.pdf · What is design? Not referring to UX (even though it’s important) Includes many things: – The components of](https://reader034.fdocuments.us/reader034/viewer/2022050409/5f85d97c163b046aac4cb90d/html5/thumbnails/118.jpg)
Experience
● Experience hones your sense of design.– Hopefully, our discussions this semester will help you be aware of it.