CEN6070-Chapter9 1
CEN6070-Chapter9 1
Chapter 9.1
Stage 4 M11
Integration B Integration c
Stage 3 M9 M10
Integration A
Stage 2 M8
Stage 1 M1 M2 M3 M4 M5 M6 M7
Stage 2 M9 M10
Stage 3 M8
Stage 4 M6 M7
Stage 5 M1 M2
Stage 6 M3 M4 M5
Module
tested in an Drive
M9 of M9
earlier
stage
M8 Module M8 Module
on test on test
Modules
Stub Stub tested in an
of M1 of M2 M1 M2 earlier
stage
Galin, SQA from theory to implementation © Pearson Education Limited 2004
Tree Class – Top Down:
Examples of Drivers and Stubs
class Tree
{
private Node root; // only data field in Tree; but key!
In main somewhere:
15
Tree Class – Example of Stubs – can do “Displays!”
class Tree
{
private Node root; // only data field in Tree; but key!
16
Fill in code incrementally…. Develop method…
public Node find (int key)
{ // assumes non-empty tree
Node current = root; // start at root
17
Insert code into placeholder as developed…
class Tree
{
private Node root; // only data field in Tree; but key!
public void find (int key)
{
Node current = root; // start at root
while (current.iData != key) // if no match
{
if (key < current.iData)
current = current.leftChild;
else
current = current.rightChild;
If (current == null)
return null; // not found; boundary condition
} // end while
return current; // returns reference to node
} // end find()
18
19 Tree Class – Bottom Up:
– Sometimes the pieces may not fit too. Structure may be off.
• Big Bang: In general, not a good approach, unless program is very small
and not terribly complicated.
– Difficult to identify errors and where they are located.
– Simply way too much code / functionality to evaluate at one time.