![Page 1: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/1.jpg)
1
Introduction
![Page 2: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/2.jpg)
2
Administrative•70% Exam, 30% Homeworks
• Must pass exam
•4-5 Homeworks
•Homework grades: 80 is easy, 100 is hard
•1-2 Class exercises
•Lecture in tutorial slot
•Office hours: by e-mail appointment• imaman@cs
![Page 3: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/3.jpg)
3
An academic course is limited …
We want to emulate• Changing requests• Partial/Underspecified requests• Project is never closed – no end point• Large teams• Large code base• Time factor – human memory is limited• Multiple users• Multiple versions• Wide area – many non-overlapping topics• Interfacing with external “things”• Lecture time is limited - cannot present complex code• Too much code vs. too much explanations
![Page 4: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/4.jpg)
4
Learning this Course
Close to social science/literature• No formulas, no proofs, no right answer• You need to forget a few things• Wide but not deep, no linear order• Extrapolation: from the simple examples to
complex scenarios
Requires a different state of mind
![Page 5: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/5.jpg)
5
Our Context
•OOP
•Mostly static typing
•Performance is not issue
•Things everyone can use
•You will write slower!
![Page 6: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/6.jpg)
6
Motivation
We need to deliver good programs• Bugs: results may be catastrophic• Project is 95% done, 80% of the time• Expensive to change: software is not “soft” (!)• In short: programs are complicated
Two issues• Definition of quality• Techniques for achieving quality
![Page 7: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/7.jpg)
7
A One-Line Summary
Write test!
![Page 8: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/8.jpg)
8
A Two-Line Summary
•Rule #1:Write test!
•Rule #2:Programming is a process of trial-and-error process
![Page 9: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/9.jpg)
9
A Slightly Deeper Summary
•Rule #1:Write test!
•Rule #2:Programming is a process of trial-and-error process
•Rule #3, #4, #5: Turing Church
•Rule #6: There is no rule #7
![Page 10: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/10.jpg)
10
The Turing & Church Rules
•A program may contain other programs
•You cannot know if a program is doing what you expect it to do
•If it can be done at all, it can be done in many ways
![Page 11: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/11.jpg)
11
Quality in Software ?
•#bugs in the present•#bugs in the future•Time to develop•Time to add a feature•Time to learn the code•LOC ?•#Users•Revenues
•Conclusions• Many contradicting factors• Measuring is hard
![Page 12: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/12.jpg)
12
Statistical Correlation
• Conduct an experiment• Measure quality once over a large enough sample• Correlate with other properties (that are easier to measure)• Similar to clinical trials
• Candidates for “other properties”• Source code metrics, development methodologies,
language/technology/tools used
• Does not work: Expensive• Sample size is too small compared to variance• Participants must be isolated of new techniques for the duration of the
experiment• Hidden bugs
• Conclusion: software metrics are very limited
• Not surprising: measuring quality seems to be at odds with Turing
![Page 13: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/13.jpg)
13
Burn Charts•Time is important. let’s describe our progress vs. time
•Vertical axis: tasks completed
•Horizontal axis: time line
![Page 14: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/14.jpg)
14
Burn Up
![Page 15: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/15.jpg)
15
Burn Up Example
![Page 16: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/16.jpg)
16
Quality in Software
•High-quality: A software whose burn curve is linear
•Similar to Big-O notation of algorithms
•Does not distinguish between two linear curves• Differences in domain, languages, …
•States that a flattening is the #1 risk• Can be experienced even in student assignments
•Result oriented• Unlike code metrics whose correlation with the net result is indirect (at
best)• Requires constant feedback, short iterations
•Past is measurable• Provides some confidence for the future
![Page 17: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/17.jpg)
17
Achieving Linear Burn Up
•The reason why people are obsessed with design
•A good design => High quality
•Two questions• What is design?• How can one achieve good design?
![Page 18: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/18.jpg)
18
![Page 19: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/19.jpg)
19
(Intelligent) Code Review
•Context• Schedule considerations• Criticality• Legacy• Not all parts of a program should be of the
same quality
•Readability• “Code is for communication”• Code is read more than written
![Page 20: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/20.jpg)
20
What is Design (I)
Sufficient information for a craftsman oftypical skill to be able the build the artifact
without excessive creativity.
(Guy Steele)
![Page 21: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/21.jpg)
21
public class Calculator { int x; public A(int n) { x = n; } public int add(int y) { return x + y; } public int sub(int y) { return x – y; }}
![Page 22: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/22.jpg)
22
Using a Calculator Object
•Compute 5 + 9, put result in x• int x = 5 + 9;• int x = new Calculator(5).add(9);
•Protocols induce a new programming language
![Page 23: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/23.jpg)
23
Class IndentingPrinter public class IndentingPrinter {
private String indentation = ""; private final StringBuilder sb = new StringBuilder();
public void inside() { indentation += " "; }
public void outside() { indentation = indentation.substring(2); }
public void print(String s) { sb.append(indentation).append(s ).append('\n'); }
@Override public String toString() { return sb.toString(); } }
![Page 24: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/24.jpg)
24
Using IndentingPrinter’s Language public class Book { private String name; public Book(String name) { this.name = name; }
public void print(IndentingPrinter p) { p.print("Book: " + name); } } public class Library { private String name; private List<Book> books = new ArrayList<Book>(); public Library(String name) { this.name = name; } public void add(Book b) { books.add(b); }
public void print(IndentingPrinter p) { p.print("Library: " + name); for (Book b : books) b.print(p); } }
![Page 25: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/25.jpg)
25
Class IndentingPrinter (II) public static class IndentingPrinter {
private final String indentation; private StringBuilder sb = new StringBuilder();
public IndentingPrinter() { this("", new StringBuilder()); } private IndentingPrinter(String indentation, StringBuilder sb) { this.indentation = indentation; this.sb = sb; } public IndentingPrinter inside() { return new IndentingPrinter(indentation + " ", sb); } public void print(String s) { sb.append(indentation).append(s).append('\n'); }
@Override public String toString() { return sb.toString(); } }
![Page 26: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/26.jpg)
26
New Protocol => New Language // Book remains the same ...
public static class Library { private String name; private List<Book> books = new ArrayList<Book>(); public Library(String name) { this.name = name; } public void add(Book b) { books.add(b); }
public void print(IndentingPrinter p) { p.print("Library: " + name); for (Book b : books) b.print(p.inside()); } }
![Page 27: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/27.jpg)
27
Which Version do you like better?
![Page 28: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/28.jpg)
28
What is Design (II)
Design is the language induced by the protocols of the objects that are available
at a certain context
![Page 29: 1 Introduction. 2 Administrative 70% Exam, 30% Homeworks Must pass exam 4-5 Homeworks Homework grades: 80 is easy, 100 is hard 1-2 Class exercises Lecture](https://reader035.vdocuments.net/reader035/viewer/2022062421/56649d385503460f94a10d96/html5/thumbnails/29.jpg)
29
“Design, by nature, is a series of trade-offs. Every choice has a good and bad side, and you make your choice in the context of overall criteria defined by necessity.
Good and bad are not absolutes, however. A good decision in one context might be bad in another. If you don't understand both sides of an issue, you cannot make an intelligent choice; in fact, if you don't understand all the ramifications of your actions, you're not designing at all. You're stumbling in the dark”
Allen Holub, “Why getter and setter methods are evil”, http://www.javaworld.com