KUNWAR ITECH7409Tutorials 09
KUNWAR ITECH7409Tutorials 09
KUNWAR ITECH7409Tutorials 09
Tutorial 9
This Tutorial sheet comprise two parts: Review Questions and Further Exercises. The Review Questions
have been designed as a revision exercise covering some of the main points covered in the lectures.
The Further Exercises are generally exploratory in nature being extensions of the lecture materials.
Students will benefit if they discuss their solutions to both parts in small groups. All questions should
be attempted and it is expected that students may need to complete some of the tutorial in their own
time. Note: some of the questions in Further Exercises may require the use of a computer with some
specific software and internet connection.
As the final exam will draw material from lectures, tutorials and assignments, students are strongly
advised to work consistently and to attend both lectures and tutorials.
Review Questions
1. Broadly speaking, what are some of the benefits of an object-oriented approach when developing a
system?
Some of the benefits of an object-oriented approach are:
The classes,objects, methods and messages supports highly cohesive units that contain both data and processes. It
leds to better communication between user and analyst and reusable objects.
Encapsulation and information hiding supports loosely coupled units which leads to reusable objects, fewer ripple
effects from changes within an object or in the system itself
Inheritance allows us to use lasses as standard templates from which other classes can be built which leads to less
redundancy,faster creation on new classes and ease in supporting exceptions
Polymorphism and dynamic binding supports minimal messaging that is interpreted by objects themselves which
leads to simpler programming of events and ease in replacing or changing objects in a system.
2. Broadly speaking, how is testing in an object-oriented approach different to testing in a traditional software
development?
Object oriented system are a collection of classes that work individually and together in a system. Every
class has its own characteristics and behaviours.Testing focuses on the class being a unit and intra-class
testing of methods and interfaces to data is similar to classical unit testing. The inter class testing including
inheritance, polymorphism and dynamic binding of objects spans integration and system testing.
Further exercises
9. Examine the class diagram for class TutoringSystem that creates ArrayLists of tutors and students.
What approach would you take to test this class?
The testing class TutoringSystem initially needs a driver class TestTutoring System for the creation of
TutoringSystem. The testing for class Tutor and class Student and class person would need to have taken place
so that the methods of this class can be tested. Else, stubs would be required to be create but this would be
more work than writing and testing the actual classes.
//*****************************************************
// ZeroComandLine.java
// revised Lewis & Loftus program, an introduction to exceptions
//*****************************************************
public class ZeroCommandLine
{ public static void main (String [ ] args)
{ int numerator ;
int denominator ;
//**************************** *****************************
// ZeroCommandLineTry.java
//************************************************************
public class ZeroCommandLineTry .
{ public static void main (String [ ] args)
{ int numerator ;
int denominator ;
try
{ numerator = Integer.parseInt( args [0]) ;
denominator = Integer.parseInt ( args
[1] );
System.out.println ( "The division is " + numerator/denominator ) ;
}
Now desk check the program with the same test data as previously. What are the expected results?