Introduction

Document Sample
Introduction Powered By Docstoc
					               1




Introduction
                                            2


                Administrative
•~80% Exam, ~20% 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
                                              3


   How to Approach this Course
•Hard to emulate the “real world”
  • Requirements/scope
  • No clear finish line
  • Months & years

•You need to treat the material differently
  • Extrapolation
  • Wide but not deep
  • Every decisions has pros and cons

•Result
  • You will write slower!
                            4


                 Context
•OOP

•Mostly static typing

•Performance is not issue
                                   5


   “Design” => “Better” software
•Define: Design

•Define: Quality in software
6
                                                      7

  What Jeremy Lin Teaches Us
         About Talent?


Lin was eventually signed by the Warriors, but he
was soon placed on the inactive list … Lin was
waived by the Warriors, picked up and then waived
by the Rockets, before finally being claimed by the
Knicks as a backup point guard.

“Frontal Cortex” (Jonah Lehrer)
                                                     8


           Statistical Correlation
•Once:
  • Pick properties that are easy to measure
  • Measure “success” indicators
  • Correlate properties and indicators


•Repeatedly:
  • Predict future success by measuring properties


•Didn’t work in the case of Jeremy Lin

•“Success” indicators in s/w are harder to measure
  • (than in sports)
9
                                   10




“A fly with no legs cannot hear”
11
                                              12


                   Analysis
•Fixes in earlier stages are cheaper
•=> Better to detect mistakes earlier
•=> “Measure twice, cut once”

How about
•Cost of fix rises with amount of knowledge
 needed to be processed by the fixer
•=> Less decisions, cheaper fixes
•=> Feedback about what’s not working makes
 fixes cheaper
                                               13


  (Jeremy Lin, Repair Cost Chart)

•Pre-estimation of success will not work

•Intensive pre-planning will not work

•Actually, we already know that
 (Computability 101)

•Try it!
•Get real feedback
•Similar to physical checks, planning a city
                             14


        A One-Line Summary
Write test!
                                                                15


              A Two-Line Summary
• Rule #1:Write test!

• Rule #2:Programming is a process of trial-and-error process
                             16


                    Axioms
• Entropy

• Discontinuity

• Long tail

• Super-linearity
                                                            17


                     Burn Charts
• Time is important. let’s describe our progress vs. time

• Vertical axis: tasks completed

• Horizontal axis: time line
          18


Burn Up
                  19


Burn Up Example
                                                                   20


                Quality in Software
• High-quality: A software whose burn curve is linear

• We don’t care about the slope. As long as it’s constant
  • Similar to Big-O notation of algorithms

• 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
                                                         21


         Quality in Software (cont.)
•High-quality: A software whose burn curve is
 linear

•A s/w dev. technique must optimize delivery time
  • “Plan for X months and code for X weeks” does not work


•A s/w dev. technique that requires, at iteration
 N+1, work that is O(N), does not work
                                                  22


         What is Design (I)

 Sufficient information for a craftsman of
typical skill to be able the build the artifact
        without excessive creativity.

                                 (Guy Steele)
                                              23




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; }
}
                                               24


       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
                                                                        25


              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(); }
}
                                                                           26


 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);
     }
 }
                                                                       27


          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(); }
}
                                                        28


     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());
    }
}
                                    29


Which Version do you like better?
                                                 30


         What is Design (II)

    Design is the language induced by the
protocols of the objects that are available at
              a certain context
                                                                    31




“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

				
DOCUMENT INFO
Shared By:
Stats:
views:32
posted:4/1/2012
language:
pages:31
Description: Jeremy Lin (Jeremy Shu-How Lin,), was born on August 23, 1988, California, USA, American professional basketball player, the main point guard, height 191 cm, weight 91 kg. Native of Fujian Province Zhangpu County, grandparents emigrated in Changhua, Taiwan, the parents emigrated to the U.S. in 1977.Jeremy Lin graduated from Harvard University, led by Harvard University basketball team won the champions of the Ivy League group, enter NCAA64 strong, and later signed with the Golden State Warriors, the first since 1953 to enter the NBA Harvard University students; the first Chinese-American to enter the NBAplayer. In December 2011, has cut the Golden State Warriors, Houston Rockets.December 27, 2011, he signed to the New York Knicks.