Senior Symposium Friday, April 16 12:30 PM 12:45 PM 2 Tuesday, - - PowerPoint PPT Presentation

senior symposium friday april 16
SMART_READER_LITE
LIVE PREVIEW

Senior Symposium Friday, April 16 12:30 PM 12:45 PM 2 Tuesday, - - PowerPoint PPT Presentation


slide-1
SLIDE 1
  • 12:30 PM

12:45 PM

Senior Symposium Friday, April 16

1 2 Tuesday, April 13, 2010

slide-2
SLIDE 2

public DnaStrand cutAndSplice(String enzyme, String splicee) {

  • int enzymeStart = dnaSequence.indexOf(enzyme);
  • if (enzymeStart == -1) {
  • return new StringDNAStrand();
  • }
  • StringBuilder recombStrand = new StringBuilder();
  • int enzymeEnd = 0;
  • while (enzymeStart != -1) {
  • numBreaks++;
  • recombStrand.append(dnaSequence.substring(enzymeEnd, enzymeStart));
  • recombStrand.append(splicee);
  • enzymeEnd = enzymeStart + enzyme.length();
  • enzymeStart = dnaSequence.indexOf(enzyme, enzymeEnd);
  • }
  • recombStrand.append(dnaSequence.substring(enzymeEnd));
  • return new StringDNAStrand (recombStrand.toString());
  • }

StringDNA Strand Building the String

dna enzyme splicee “ACGTGAGTGG” “GTG” “AAAA ”

recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee);

“ACAAAA ”

3 4 Tuesday, April 13, 2010

slide-3
SLIDE 3

Building the String

dna enzyme splicee “ACGTGAGTGG” “GTG” “AAAA ”

recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee);

“ACAAAAAAAAA ”

Building the String

dna enzyme splicee “ACGTGAGTGG” “GTG” “AAAA ”

recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee);

“ACAAAAAAAAAG” On each append call, we copy the splicee into the StringBuilder.

5 6 Tuesday, April 13, 2010

slide-4
SLIDE 4

public DnaStrand cutAndSplice(String enzyme, String splicee) {

  • if (head.getNext() != null) {
  • throw new IllegalStateException

("Cannot cut and splice a link strand containing more than one node.");

  • }
  • LinkedListDNAStrand recombStrand = new LinkedListDNAStrand();
  • int enzymeStart = head.value.indexOf(enzyme);
  • if (enzymeStart == -1) {
  • return recombStrand;
  • }
  • int enzymeEnd = 0;
  • while (enzymeStart != -1) {
  • numBreaks++;
  • recombStrand.append(head.value.substring(enzymeEnd, enzymeStart));
  • recombStrand.append(splicee);
  • enzymeEnd = enzymeStart + enzyme.length();
  • enzymeStart = head.value.indexOf(enzyme, enzymeEnd);
  • }
  • recombStrand.append(head.value.substring(enzymeEnd));
  • return recombStrand;
  • }

LinkedList DNAStrand

private LinkedListDNAStrand append(String dna) {

  • Node newNode = new Node(dna);
  • if (head == null) {
  • head = newNode;
  • }
  • else {
  • tail.setNext(newNode);
  • }
  • tail = newNode;
  • length = length + dna.length();
  • return this;

}

  • public Node (String value) {
  • this.value = value;
  • }

LinkedList DNAStrand

recombStrand.append(splicee); We construct the linked list without ever copying the splicee! splicee, dna, value all refer to the same String object

7 8 Tuesday, April 13, 2010

slide-5
SLIDE 5

Building the Linked List

dna enzyme splicee “ACGTGAGTGG” “GTG” “AAAA ” “AC” “A ” “G”

recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee);

Making the splicee longer does not increase the cost

  • f building the

linked list!

Goal of Testing

Demonstrate that the program is correct What does “correct” mean? It meets its specification What if the specification is wrong?!? NOT a proof that the program is correct! Specification: English description of what the program should do. 9 10 Tuesday, April 13, 2010

slide-6
SLIDE 6

General Testing Strategy

Want to generalize from the test input to make claims about all input Divide input into a set of equivalence classes Choose 1 (or a small number) of test input from each equivalence class Assume that if the program works on the test input, it will work on all input.

KEY: Pick your equivalence classes well!

Finding Equivalence Classes

Black-box testing Examine the specification White-box testing Examine the code 11 12 Tuesday, April 13, 2010

slide-7
SLIDE 7

White Box Testing

Execute every statement Execute every true & false branch Loops: 0 iterations 1 iteration many iterations Boundary conditions: minimal values maximal values

White Box Testing Example

/ / Return the index where the value is in a. Return -1 / / if the value is not in the array. / / Precondition: a must be sorted. int search (int[] a, int value) { for (int i = 0; i < a.length; i++) { if (a[i] == value) { return i; } }

  • return -1;

}

13 14 Tuesday, April 13, 2010

slide-8
SLIDE 8

White Box Testing Example 2

/ / Return the index where the value is in a. Return -1 / / if the value is not in the array. / / Precondition: a must be sorted. int search (int[] a, int value) { int low = 0; int high = a.length - 1; int middle; while( low < high ) {

  • middle = ( low + high ) / 2;
  • if( value == a[middle] )
  • return middle;
  • else if( value < a[middle] )
  • high = middle - 1;
  • else
  • low = middle + 1;
  • }
  • return -1;

}

Testing Phases

Unit testing - test individual class Integration testing - test groups of interacting classes System testing - test entire system integrated with real hardware, databases, etc. Acceptance testing - testing done by customer to decide if software does what they want

Our emphasis

15 16 Tuesday, April 13, 2010

slide-9
SLIDE 9

“code-a-little, test-a-little”

Allows us to find errors early Leaves less question about where the error

  • is. It’

s probably in the code we just wrote. Test-driven development - develop test program BEFORE the code to be tested!

Structured Walkthroughs

Carefully trace your code to be sure it does what you intend. Don’ t take shortcuts. Best to do with another person. Explain the code. Let the other person critique. 17 18 Tuesday, April 13, 2010

slide-10
SLIDE 10

Structured Walkthrough Example

/ / Return the index where the value is in a. Return -1 / / if the value is not in the array. / / Precondition: a must be sorted. int search (int[] a, int value) { int low = 0; int high = a.length - 1; int middle; while( low < high ) {

  • middle = ( low + high ) / 2;
  • if( value == a[middle] )
  • return middle;
  • else if( value < a[middle] )
  • high = middle - 1;
  • else
  • low = middle + 1;
  • }
  • return -1;

}

19 Tuesday, April 13, 2010