You are on page 1of 2

Practical 4

Mr Andrew Cook
14 February 2022

Introduction
I am not setting any specific problems for this practical class, instead you should
use this as an opportunity to revisit the work done in the first three practical
sessions from a viewpoint of the principles of Object-Oriented programming
discussed in lecture 1.

Suggestions
Look back at the code you’ve produced so far:
How well do your comments explain what is being done by each class? By
each method?
Are there any places where errors are likely to occur? What simple tests
could you develop that might represent ways users may accidentally misuse the
programs you have written, can you include try-except blocks to handle these
errors in a way that a user can understand what has occurred?
If a user wished to use a specific module you have written independently (for
instance the binary heap implementation) how could you make this possible?
What if a user wished to import this module into another piece of code they
were writing.
Hint: if name ==’ main ’
In practical three we created a number of different implementations of Binary
Trees.
From a viewpoint of Inheritance:
Could you create a SuperClass of Binary Tree and using inheritance create
specialise a SubClass for each of the uses described in the practical.
Similarly many of the operations can be performed recursively - the nodes
within the tree can perform elements of the operations without a controlling
class making the ’decisions’. You could create a ”Binary Tree Node” SuperClass
and then for the specialised uses create specialised SubClass implementations
to perform the logic required.
From a viewpoint of Polymorphism:

1
When creating an object for many of the problems we have implemented
often we will create an empty form of the structure in question, potentially
adding inputs using an externally created node.
How could we re-write these classes so when they are created they can create
an Empty form, but also if presented a single object (or number) they create
the first steps of the structure?
How could we extend this to allow a list to of data to be presented and
correctly inserted into the data structure?

You might also like