Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review of Previous Lesson

Similar presentations


Presentation on theme: "Review of Previous Lesson"— Presentation transcript:

1 Review of Previous Lesson
25/05/2019 Review of Previous Lesson State as many Vocabulary words and Learning Objectives that you remember from the last lesson as you can. Remember to grade yourself from

2 Conditionals & Control Flow
25/05/2019 Conditionals & Control Flow Complex Multiple Conditions

3 Language Features and other Testable Topics
25/05/2019 Tested in the AP CS A Exam Notes Not tested in the AP CS A Exam, but potentially relevant/useful Operators Logical: !, &&, || 1, 3 Control Statements if, if/else

4 Language Features and other Testable Topics
25/05/2019 Notes: 1. Students are expected to understand the operator precedence rules of the listed operators. 3. Students need to understand the “short circuit” evaluation of the && and ||

5 25/05/2019 Program Analysis The analysis of programs includes examining and testing programs to determine whether they correctly meet their specifications. It also includes the analysis of programs or algorithms in order to understand their time and space requirements when applied to different data sets.

6 Program Analysis A. Testing B. Debugging C. Runtime exceptions
25/05/2019 Program Analysis A. Testing 1. Development of appropriate test cases, including boundary cases 2. Unit testing 3. Integration testing B. Debugging 1. Error categories: compile-time, run-time, logic 2. Error identification and correction 3. Techniques such as using a debugger, adding extra output statements, or hand-tracing code. C. Runtime exceptions

7 25/05/2019 Black box testing Use of different input values to determine whether the program gives you expected results (compare actual results with expected ones) and can cope with them without crashing. These values should include Different types of input e.g. Typical values Borderline values Unacceptable values Do not look into the program (box) all you see are the inputs (what goes in) and outputs (what comes out at the end).

8 Example 1 of Black Box Testing
25/05/2019 Example 1 of Black Box Testing A program which uses marks out of 100 from a math's examination as input. Normal data like: 27, 73.., Borderline data: 0 and 100 Invalid data like: –34, 123, Note that you should try one piece of invalid data at a time otherwise, if there is an error or problem, you will not be able to tell which piece of invalid data is causing the problem (one, more than one or all). For example using means that, if there was an error, you would not know if it was because you used a negative (-) number or because you used a decimal (real) number. You should use -16 and then (in any order) first, if there are no errors, then you could try

9 Manual White Box Testing / Dry Runs / Desk Checking
25/05/2019 Manual White Box Testing / Dry Runs / Desk Checking Basically manually Tracing or Variable Watching with a table which the programmer fills in. FirstNumber SecondNumber Total

10 There are 2 main types program error (bug)
25/05/2019 There are 2 main types program error (bug)

11 1. Syntax errors / Compile-time errors
25/05/2019 1. Syntax errors / Compile-time errors Discussed in the “How to Compile & Run your First Java Program” presentation. Programming languages have a particular format you have to stick to when telling the computer what to do. This format is called syntax. When code is written in a way that the computer can understand, we say the code is syntactically correct. When the code is written in a way the computer cannot understand, we say there is a syntax error. Please also note that Java is case sensitive. Almost all syntax errors will stop Javac from compiling a program, if so they are also known as ‘compile-time errors’.

12 25/05/2019 2. Logic errors (can also be known as run-time errors if found when a program is run) A mistake in the way the program solution has been designed. e.g. An instruction in a program may tell the computer to jump to the wrong part of the program. Total_number = Previous_total – New_number Known as logic errors if found whilst not running a program and using white box testing. Can also be known as run-time errors if found when actually running a program during black box testing. Don’t necessarily lead to a program ‘crashing’, may just lead the program to give incorrect/unexpected results. This does mean to say that logic errors will not make a program ‘crash’ (e.g. division by 0 will lead a program to crash if code is not written to deal with it), just not necessarily. This is known as a “runtime exception” as it is not checked by Javac during compile time.

13 25/05/2019 Write your own programs: Write your own programs from “scratch”. Of course you should use previous programs for reference, but write your code from “scratch” (do not copy and paste).

14 Rent a property Specification: 25/05/2019
Illustrate complex multiple conditions: More specifically to illustrate the order of precedence of the And & Or logical operators. A customer wants to rent a holiday property which has 4 or more bedrooms, and it must be a cottage (C) or a detached (D) house. Start with the following code: Run the program and test all possibilities. You should find a problem! What is it? Please solve and explain the issues in a comment. Note: I believe the terms ‘cottage’ & ‘detached’ are British terms. Other types of houses are terraced (‘T’), semi-detached (‘S’), ‘flat’ (‘F’), (‘apartment’ (‘A’), etc…. You can look up these terms in Google or Bing etc.. images on the net. Continued on the next slide.

15 25/05/2019 Rent a property You should find that if it is a cottage and the number of bedrooms is lower than 4 the program still says ‘Rent it!’. This is because && is done before ||. So the program interprets the code like this: type == "C" Or type == "D" And bedrooms >= 4 So if it is Detached then this works as both the type and the number of bedrooms has to be true but if it is a cottage then the type or the number of bedrooms is required to be true; so it doesn’t work. How can we fix this? See if you can fix this yourself before looking at the solution on the next slide. Continued on the next slide.

16 Rent a property How can we fix this? 25/05/2019
Replace the previous code with:

17 Deciding Exam Grades Extended 2
25/05/2019 Deciding Exam Grades Extended 2 Change the “Deciding Exam Grades” Program written in a previous presentation. Use a logical expression that is true when the mark is within the range and false when the mark is outside the range of 0 – 100 and. Therefore use one IF statement with an initial IF test with And, to test if the mark is valid proceeded with a nested IF statement to produce the appropriate valid messages: Merit (60 or more), Pass (40 – 59), Fail (under 40). With a final “Else” to produce the general error message: “You have entered an invalid mark!” Note: Make a copy of the previous program to keep the original program but rename it.

18 5/25/2019 Grade yourself Grade yourself on the vocabulary and learning objectives of the presentation.


Download ppt "Review of Previous Lesson"

Similar presentations


Ads by Google