ple where a Person object is expected.
Any object present on the object bench
can be passed as a parameter (as long as
the type matches) by simply clicking it
when the parameter dialog box pops up.
State
BlueJ offers an inspector capability
that allows us to open an object and
look inside it (see Figure 5). It is highly
educational to look into two or three
objects of the same class and observe
their fields. We can see that they all have
the same fields, but their values differ.
We can even make calls to an object’s
methods while the inspector is open to
observe the values changing. This rein-
forces another important concept: state.
In BlueJ, we start with the clean principles and add the idiosyncrasies of the
language later. You can, of course, have a
main method and use it if you want to. It
will appear (together with all public static
methods) in the class’ menu, where it
can be invoked. However, it is nothing
special and can be introduced if and
when students are ready to really understand the meaning of public, static, void,
and String[].
Yes, Really: No main Method
If you played along until now, and you’re
used to writing Java programs, you
will have noticed one thing: no main
method. Yes, that’s right: there is no
main method!
The main method is an extremely ugly
hack for connecting a Java program to
the operating system. It has nothing
whatsoever to do with object orientation
and has confused students ever since it
was first shown.
The Code Pad
Another very useful educational tool is
the Code Pad. The Code Pad is visible at
the bottom right in Figure 1. It allows us
to type individual expressions or statements, which are then immediately
executed. For expressions, the result
is immediately displayed in the Code
Pad. If the result is an object, it can be
dragged across to the object bench for
further investigation.
The Code Pad is very useful for stu-
dents to quickly and easily try out arbi-
trary code snippets to see what they do.
COMMUNITY
JAVA IN ACTION
Figure 6
to teach the fundamentals of Java and
object orientation to beginners. Until
then, get BlueJ installed on your system
and start experimenting! </article>
ABOUT US
LEARN MORE
•;Java SE 7 API
The Editor
BlueJ’s text editor highlights scopes,
such as methods, if statements, and
loops with different background coloring (see Figure 6). This is another educationally valuable visualization. The
coloring supports the understanding
of scoping, and errors in scope become
much more easily apparent.
probably the most convenient method
of any environment for creating JUnit
tests. In addition to the standard writing of test classes, interactive testing
and regression testing can be combined.
We can perform a sequence of interactive tests and record this interaction as a
JUnit test case to be replayed later.
We will discuss this functionality
in more detail in a later article in this
magazine.
Unit Testing
Unit testing (using JUnit) is closely integrated in BlueJ. In fact, BlueJ provides
Conclusion
In this article, I presented a quick overview of the most important tools of the
BlueJ environment. From the next article
onward, we will look at a specific project,
and discuss how these tools can be used