senior symposium friday april 16
play

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


  1. �������������������������� ������������������������ � ����������� ��������������������� ����������������� �������������������������������� ��������������������� ��������������������������������������������������������������������������������������������������������� ����������������� ����������������������������������� ����������������� ����������������� ��������������������� ����������������������������� �������������������� 1 Senior Symposium Friday, April 16 12:30 PM 12:45 PM 2 Tuesday, April 13, 2010

  2. public DnaStrand cutAndSplice(String enzyme, String splicee) { � int enzymeStart = dnaSequence.indexOf(enzyme); � � StringDNA � if (enzymeStart == -1) { � � return new StringDNAStrand(); � � } Strand � � � 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()); � } 3 Building the String dna “ACGTGAGTGG” enzyme “GTG” splicee “AAAA ” “ACAAAA ” recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee); 4 Tuesday, April 13, 2010

  3. Building the String dna “ACGTGAGTGG” enzyme “GTG” splicee “AAAA ” “ACAAAAAAAAA ” recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee); 5 Building the String dna “ACGTGAGTGG” enzyme “GTG” splicee “AAAA ” On each append call, “ACAAAAAAAAAG” we copy the splicee into the StringBuilder. recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee); 6 Tuesday, April 13, 2010

  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) { LinkedList � � return recombStrand; � � } � int enzymeEnd = 0; DNAStrand � 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; � } 7 recombStrand.append(splicee); LinkedList private LinkedListDNAStrand append(String dna) { DNAStrand � Node newNode = new Node(dna); � if (head == null) { � � head = newNode; � } splicee, dna, value all � � else { refer to the same � � tail.setNext(newNode); String object � } � tail = newNode; � � length = length + dna.length(); � We construct the linked � return this; } list without ever copying the splicee! � � public Node (String value) { � � � this.value = value; � � } 8 Tuesday, April 13, 2010

  5. Building the Linked List Making the splicee dna “ACGTGAGTGG” longer does not enzyme “GTG” increase the cost splicee “AAAA ” of building the linked list! “G” “AC” “A ” recombStrand.append(dna.substring(enzymeEnd, enzymeStart)); recombStrand.append(splicee); 9 Goal of Testing Demonstrate that the program is correct What does “correct” mean? It meets its specification Specification: English description of what the program should do. What if the specification is wrong?!? NOT a proof that the program is correct! 10 Tuesday, April 13, 2010

  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! 11 Finding Equivalence Classes Black-box testing Examine the specification White-box testing Examine the code 12 Tuesday, April 13, 2010

  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 13 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; } 14 Tuesday, April 13, 2010

  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; } 15 Testing Phases Our emphasis 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 16 Tuesday, April 13, 2010

  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! 17 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. 18 Tuesday, April 13, 2010

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend