Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (29 sloc) 2.6 KB

Predict the Future

OzCode performs predictive analysis of code execution (or as we like to call it: Fortune telling!)

Overview

OzCode predicts the future! You'll see an arrow pointing to where we’re going to go when we hit F10, and irrelevant code paths are made semi-transparent. Predict brings a new meaning to the term “Living Coding”ת by giving you instant feedback on changes you make as you’re debugging, allowing you to fix silly little coding mistakes extremely quickly.

Using Predict

In order to run this demo click the Predict button in the demo application.

Predict button

You should stop at the beginning of a method.
Place a breakpoint at the line of the switch statement and continue the debug run (F5).

First breakpoint

Once you reach the breakpoint you may notice a few things: The case that will be taken is the only one not grayed out (Gender.Female), and there's an arrow pointing to the beginning of that case.

Stopping at the first breakpoint

Continue running - the next time the debugger stops at the breakpoint, the grayed out sections will change to show the next executed instruction - case Gender.Male in this case.

Stopping at the first breakpoint

Press F10 to move to the next instruction, and the if clause should light up. The red represents conditions that failed, while the passing (true) conditions are marked in green. All of this is analyzed before the code runs.

Predict if statments

Since the total result of the four conditions is true, a green 'V' appears near the if and a yellow arrow appears near the beginning of the clause body.

Now add a breakpoint at the beginning of SendThankYouLetter(Customer customer)

Second breakpoint

And Run until you stop at the beginning of the method - can you spot the bug?

If you're using VS2015 you'll be able to use Edit & Continue and replace the '>' with '<='.

Second bug fixed

Press F5 to continue debugging. The next time you reach the method another problem will arise. OzCode knows that the next instruction executed will cause a NullReferenceException. The origin of that exception is marked in Red (EmailAddress).

Exception prediction

Now that we know what the bug is, it's easy to fix it by making sure that the if clause can handle null email addresses.

Back to Main