OOPDA Intro 5.0. Topics Website and Syllabus Rowan VPN and H:drive BlueJ application and projects Programming Style (Appendix J) Javadoc (Appendix I)

Slides:



Advertisements
Similar presentations
Chapter 10 Introduction to Arrays
Advertisements

Comp1004: Building Better Classes I Testing and Debugging Partly based on BlueJ Book – Chapter 6.
More sophisticated behaviour Using library classes to implement some more advanced functionality.
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Well-behaved objects Debugging. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Prevention vs Detection.
Objects First with Java A Practical Introduction using BlueJ
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Well-behaved objects Improving your coding skills 1.0.
Testing and Debugging. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling (Reminder) Zuul Assignment Two.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
Make Sure You Know All This!. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 2 Objects and Classes.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Object interaction Creating cooperating objects 5.0.
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
More sophisticated behavior Using library classes to implement some more advanced functionality 3.0.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
CS1101: Programming Methodology Aaron Tan.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
1 Shawlands Academy Higher Computing Software Development Unit.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
More sophisticated behavior Using library classes to implement some more advanced functionality 5.0.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
The Software Development Process
Week81 APCS-AB: Java Unit Testing Information today from “Unit Testing in BlueJ” October 28, 2005.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Testing. Have you contacted your project members lately?
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
1 COS 260 DAY 10 Tony Gauvin. 2 Agenda Questions? 4 th Mini quiz Today –Chapter 4 Assignment 2 Due Capstone Discussion Proposals Due Oct 15 No class on.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
Software Quality Assurance and Testing Fazal Rehman Shamil.
1 COS 260 DAY 15 Tony Gauvin. 2 Agenda Questions? 6 th Mini quiz Today –Chapter 6 Assignment 4 posted –Due Nov 9 Capstone progress reports are due –Brief.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Chapter – 8 Software Tools.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
6.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability © 2017 Pearson Education, Inc. Hoboken,
Review. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Objects and Classes Objects and Classes –State.
Objektorienterad programmering d2, förel. 6
Objects First with Java
More Sophisticated Behavior
Objects First with Java A Practical Introduction using BlueJ
Objects First with Java Creating cooperating objects
Objektorienterad programmering d2, förel. 6
Chapter 8 – Software Testing
Testing and Debugging.
COS 260 DAY 17 Tony Gauvin.
More sophisticated behavior
Objects First with Java
COS 260 DAY 16 Tony Gauvin.
COS 260 DAY 15 Tony Gauvin.
Exercise 1 Declare a constant of type int called SIZE and initialize it to value 10 Declare two int arrays of size “SIZE” Assume that those int arrays.
COS 260 DAY 16 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
Objects First with Java A Practical Introduction using BlueJ
Classes CS 21a: Introduction to Computing I
CSE 1020:Software Development
Presentation transcript:

OOPDA Intro 5.0

Topics Website and Syllabus Rowan VPN and H:drive BlueJ application and projects Programming Style (Appendix J) Javadoc (Appendix I) Debugger (Appendix F) Unit Testing (Appendix G)

3 Code completion The BlueJ editor supports lookup of methods Use Ctrl-space after a method-call dot to bring up a list of available methods Use Return to select a highlighted method Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

4 Code completion in BlueJ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

5 Prevention vs Detection (Developer vs Maintainer) We can lessen the likelihood of errors –Use software engineering techniques, like encapsulation –Pay attention to cohesion and coupling We can improve the chances of detection –Use software engineering practices, like modularization and good documentation We can develop detection skills Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

6 Modularization and interfaces Applications often consist of different modules –e.g. so different teams can work on them The interface between modules must be clearly specified –Supports independent concurrent development –Increases the likelihood of successful integration Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

7 Method headers as a (class) interface // Return the value to be displayed. public int getDisplayValue(); // Call when a digit button is pressed. public void numberPressed(int number); // Plus operator is pressed. public void plus(); // Minus operator is pressed. public void minus(); // Call to complete a calculation. public void equals(); // Call to reset the calculator. public void clear(); * Interface is shown in the javadoc documentation!!

8 Writing class documentation User classes should be documented the same way library classes are Others should be able to use your class without reading the implementation Make your class a potential library class Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

9 Elements of documentation Documentation for a class should include: the class name a comment describing the overall purpose and characteristics of the class a version number the authors’ names documentation for each constructor and each method Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

10 Elements of documentation The documentation for each constructor and method should include: the name of the method the return type the parameter names and types a description of the purpose and function of the method a description of each parameter a description of the value returned Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

11 javadoc Class comment: /** * The Responder class represents a response * generator object. It is used to generate an * automatic response. * Michael Kölling and David J. Barnes 1.0 ( ) */ Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

12 javadoc Method comment: /** * Read a line of text from standard input (the text * terminal), and return it as a set of words. * prompt A prompt to print to screen. A set of Strings, where each String is * of the words typed by the user */ public HashSet getInput(String prompt) {... } Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

13 Javadoc Appendix I DEMO README.txt Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

14 We have to deal with errors Early errors are usually syntax errors –The compiler will spot these Later errors are usually logic errors –The compiler cannot help with these –Also known as bugs Some logical errors have no immediately obvious manifestation –Commercial software is rarely error free Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

15 Errors Syntax * Errors in the code text itself * Found when compiling with unrecognizable text * Fix by editing code Logic * Errors in the behavior of the program * Found when running with unexpected results * Fix by debugging and observing states Runtime * Errors which prohibit program from running * Found when executing the program * Fix by editing code and debugging

16 BlueJ debugger

17 BlueJ debugger Debuggers are both language-specific and environment-specific –BlueJ has an integrated debugger Set breakpoints to halt program Step and Step-into controlled execution through code Call sequence (stack) Examine variables and object states

18 BlueJ debugger Appendix F DEMO Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

19 Debugging It is very important to develop code reading and tracing skills –Debugging will often be performed on others’ code Various techniques and tools exist to support the debugging process Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

20 Manual walkthroughs Review of printed (hard) copies Relatively under-used –A low-tech approach –More powerful than appreciated Get away from the computer! Run a program by hand High-level (Step) or low-level (Step into) views Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

21 Tracing object state An object’s behavior is largely determined by its state … … so incorrect behavior is often the result of incorrect state Tabulate the values of key fields Document state changes after each method call Tracing of object state changes Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

22 Verbal walkthroughs Explain to someone else what the code is doing –They might spot the error –The process of explaining might help you to spot it for yourself Group-based processes exist for conducting formal walkthroughs or inspections Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

23 Print statements The most popular technique No special tools required All programming languages support them Only effective if the right methods are documented Output may be voluminous! Turning off and on requires forethought Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

24 Choosing a test strategy Be aware of the available strategies Choose strategies appropriate to the point of development Automate whenever possible –Reduces tedium –Reduces human error –Makes (re)testing more likely Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

25 Review Errors are a fact of life in programs Good software development techniques can reduce their occurrence Testing and debugging skills are essential Practice a range of debugging skills Make testing a habit Automate testing where possible Continually repeat tests Regression test and use unit testing Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

26 Unit testing Application testing can only be done after entire application is completed Unit testing of any single unit can be done once written and compiled Each unit of an application may be tested –Method, class, module (package in Java) Can (should) be done during development –Finding and fixing early lowers development costs (e.g. programmer time) –A test suite is built up

27 Testing fundamentals Understand what the unit should do – its contract (requirements) –You will be looking for violations –Use positive tests and negative tests (include null and empty conditions) Test boundaries –Zero, One, Full Search an empty collection Add to a full collection Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

28 Test automation Good testing is a creative process, but thorough testing is time consuming and repetitive Regression testing involves re-running tests that have previously passed Use of a test rig or test harness can relieve some of the burden –Program to automate testing conditions Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

29 Test harness Additional test classes are written to automate the testing Objects of the harness classes replace human interactivity Creativity and imagination required to create these test classes Test classes must be kept up to date as functionality is added Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

30 JUnit Appendix G DEMO Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling

31 online-shop-junit project Show unit testing tools in BlueJ –Tools -> Preferences -> Interface Create test class and methods –Create Test Class for a class –Create Test Method for the test class o Naming begins with test ( e.g. testTwoComments) o Record test of SalesItem object & 2 comments o Ensure assertions are the expected results o End button to stop recording of test Run Tests, Test All or each method indiv. Create initial objects with setup method –Use Object Bench to Test Fixture

32 JUnit JUnit is a Java test framework Test cases are methods that contain tests Test classes contain test methods Assertions are used to assert expected method results Fixtures are used to support multiple tests Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling