Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.

Slides:



Advertisements
Similar presentations
Comp1004: Building Better Classes I Testing and Debugging Partly based on BlueJ Book – Chapter 6.
Advertisements

Using interfaces Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling How would you find the maximum.
Programming Creating programs that run on your PC
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
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.
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.
Object interaction Creating cooperating objects 5.0.
Object interaction Creating cooperating objects 5.0.
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
PRE-PROGRAMMING PHASE
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
CS1101: Programming Methodology Aaron Tan.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
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.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Programming Lifecycle
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 5.0.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
COS 260 DAY 5 Tony Gauvin.
The Software Development Process
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
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.
OOPDA Intro 5.0. Topics Website and Syllabus Rowan VPN and H:drive BlueJ application and projects Programming Style (Appendix J) Javadoc (Appendix I)
Testing. Have you contacted your project members lately?
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
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.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
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.
Wrapper Classes Debugging Interlude 1
Objektorienterad programmering d2, förel. 6
Objects First with Java
Objects First with Java Creating cooperating objects
Objektorienterad programmering d2, förel. 6
CS1101X Programming Methodology
COS 260 DAY 17 Tony Gauvin.
Unit# 8: Introduction to Computer Programming
TRANSLATORS AND IDEs Key Revision Points.
Objects First with Java
Problem Solving Techniques
COS 260 DAY 16 Tony Gauvin.
Chapter 1 Introduction(1.1)
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 Creating cooperating objects
Objects First with Java Creating cooperating objects
Presentation transcript:

Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1

2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to be covered Testing Debugging Test automation Writing for maintainability

3 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 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.

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

5 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Testing and debugging These are crucial skills. Testing searches for the presence of errors. Debugging searches for the source of errors. –The manifestation of an error may well occur some ‘distance’ from its source.

6 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Testing and debugging techniques Unit testing (within BlueJ) Test automation Manual walkthroughs Print statements Debuggers

7 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Unit testing 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.

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

9 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Unit testing within BlueJ Objects of individual classes can be created. Individual methods can be invoked. Inspectors provide an up-to-date view of an object’s state. Explore through the diary-prototype project.

10 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Test automation Good testing is a creative process, but thorough testing is time consuming and repetitive. Regression testing involves re-running tests. Use of a test rig or test harness can relieve some of the burden. –Classes are written to perform the testing. –Creativity focused in creating these.

11 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Test automation Explore through the diary-testing project. –Human analysis of the results still required. Explore fuller automation through the diary-test-junit projects. –Intervention only required if a failure is reported.

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

13 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Modularization in a calculator Each module does not need to know implementation details of the other. –User controls could be a GUI or a hardware device. –Logic could be hardware or software.

14 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Method signatures as an interface // Return the value to be displayed. public int getDisplayValue(); // Call when a digit button is pressed. public void numberPressed(int number); // Call when a plus operator is pressed. public void plus(); // Call when a minus operator is pressed. public void minus(); // Call to complete a calculation. public void equals(); // Call to reset the calculator. public void clear();

15 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Debugging It is important to develop code- reading skills. –Debugging will often be performed on others’ code. Techniques and tools exist to support the debugging process. Explore through the calculator- engine project.

16 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Manual walkthroughs Relatively underused. –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.

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

18 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 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.

19 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 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.

20 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 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.

21 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Debuggers Debuggers are both language- and environment-specific. –BlueJ has an integrated debugger. Support breakpoints. Step and Step-into controlled execution. Call sequence (stack). Object state.

22 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Review Errors are a fact of life in programs. Good software engineering techniques can reduce their occurrence. Testing and debugging skills are essential. Make testing a habit. Automate testing where possible. Practise a range of debugging skills.