Starting from:
$35

$29

Lab 2: Debugging Solution

In this lab, you will become familiar with debuggers.

Working individually you will debug a few programs. While the defects in the programs of this lab may not be complicated, use the time to become familiar with how your debugger works before you are faced with complex code.

Do not resort to debugging in this lab using print statements.


Preparation

Download HfxDonairExpress.java, Ackermann.java, and LinkedListTest.java from Lab 2 in Brightspace


Resources

A debugger which allows inspecting variables, breakpoints, stack traces


Procedure

Lab steps

    1. Run HfxDonairExpress on some inputs. You do not need to check invalid input.

    2. Examine the output until you  nd an incorrect value.

    3. Set a breakpoint at the start of the program.

    4. Select a defect in the program.

    5. Run your program in the debugger and step through the program to identify where the defect happens in the code.

    6. Determine what could  x the defect.

    7. Implement your  x and re-test to ensure that the defect is  xed.

    8. Repeat until no defects remain.

Repeat these steps for Ackermann.java and LinkedListTest.java.




1
Analysis

What strategy or strategies for debugging are most e ective for you?

What makes them e ective?

For which conditions of the code will your strategies be e ective or ine ective?

How can a debugger support your strategies?


Reporting

    1. In one  le, list

The cause of the defects that you found.

The approach that let you locate the defect.

The approximate amount of time it took you to locate the defect. The answers from the questions in the Analysis section of the lab.

    2. Generate a PDF from the document.

    3. Submit the PDF and your Java les in Brightspace in the Lab/Lab 2 section of the course page in Brightspace.


Assessment

The assessment will be on a letter grade and will re ect how well you are demonstrating that you are using and understanding debugging strategies and support tools like the debugger. I am more concerned with your familiarity with the debugging process than on nding and xing every bug in the lab code.
























2

Letter grade
Defects detected and
Strategies to locating
Analysis thoughts on
Analysis
on

how

xed


the defects


e ective
debugging
the
debugger

sup-








strategies
(higher
ports
the
debugging








weight)




strategies




A



















(Excellent)
All defects  xed with
Di erent
strategies
Demonstrates

an
Connects
the debug-

minimal code changes
for
the
types
of
understanding of
the
ger features with the




defects


bene ts  and  limi-
strategies. More than








tations  of  di erent
one
feature

might








strategies



support one strategy
B



















(Good)
All defects identi ed
Has two strategies for
Demonstrates an ap-
Knows
how
a
set

and 75% of them are
debugging


preciation for di er-
of debugger
features

xed






ent debugging strate-
supports one strategy








gies in di erent cases







C



















(Satisfactory)
All defects identi ed
Used
the
debugger
Has at least one strat-
Can see how one de-

and a start is made on
to trace through
the
egy other than
print
bugger
feature
helps

xing them

code to  nd bugs

statements
in
mind
with debugging










and knows
when
to















use it or to abandon















it











D



















(Marginal Pass)
Some
defects identi-
Resorted
to   some
Repeating
what
we
Knows how the de-

ed and  xed

print
statements
to
might  nd on the web
bugger
can
at

least




detect bugs


about debugging but
avoid debugging with








not showing that they
a pile of print state-








understand
when
to
ments













use what










F



















(Inadequate)
Little
clarity
on
Fell to  xing code by
Little
understanding
Unsure
on  how
the

what’s
wrong
with
perturbing it until it
of how
to
approach
debugger
will

help

the programs

worked


debugging in the large
with debugging










context









































3

More products