Visual Assertions

Here's a simple way to do conditional connections in the VCE, though not the most "normal"...  hey, I'm weird, what can I say...

Define a "conditional" method to choose whether or not we want to do something.  For example: "is the sky blue."

public void assertSkyBlue() {

    if (!skyBlue)

      throw new RuntimeException("");



Note that this doesn't do anything except throw an exception if the sky isn't blue.

If you use this approach, do not call the method isSkyBlue() -- that implies it's a boolean property of a JavaBean...

VisualAge thinks of this as

  sky isn't blue == exceptionOccurred

  sky is blue    == normal result          

So we can bastardize this into making a conditional connection.  To try it:

When you run this, you'll see that it takes two button presses to set the text.

This example isn't terribly interesting, but it shows that it works.

However, exceptions are somewhat expensive -- make sure the "normal" behavior you expect is the one that does not throw the exception.  Then again, in a GUI app it's not really noticeable.