[Bluej-discuss] Execute BlueJ
Stephen Bloch
sbloch at adelphi.edu
Wed May 3 14:56:17 BST 2006
Frans writes:
>I download the tutorial, and in pag e 8 said that to execute we must
>right click and choose the method.
>
>in my opinion, run the code usually using main args
>
>anyone have a tips for this? why you approaceh using method?
>
>i see the different paradigm to execute java class in bluej, what is the
>best way to explain about this?
As others have pointed out, pedagogical reasons.
One of my principles for teaching beginning programming is to teach
only those language features that are necessary in order to teach a
particular programming principle, and to teach them one at a time
when they're actually needed.
If you start with "public static void main(String[] args) { ... }",
you have an unattractive choice:
(a) you can try to explain access specifiers, static methods, return
types and the lack thereof, data types, arrays, and parameter
declarations, all on the first day of the term, or
(b) you can tell students "Just copy this down and trust me, you'll
understand it by the end of the semester."
Naturally, everybody chooses (b), but wouldn't it be nice to have
students writing code that they actually UNDERSTAND? Wouldn't it be
nice if the only syntax they needed was actually RELEVANT to the
problem they were trying to solve?
Another pedagogical benefit is ease of testing. If your program can
only be invoked from a "main" method, then every time you want to
test a new or modified part of the program, you have to modify the
"main" method to make appropriate calls to that part, and check or
output the answers. To avoid some of this re-coding, you'll probably
write the "main" method to get its testing data from input, which
means you can't automate your test suites, which means regression
testing is a hassle and you're unlikely to do it, which means that
when you make a modification to one part of the program that breaks
another part, you won't find out about it immediately. By contrast,
if you can easily write and invoke testing methods directly, it's
easier to automate test suites than to type in the testing data every
time, and regression testing takes one or two mouse clicks so you'll
probably actually do it.
Yet another is that you can (if you wish) postpone the treatment of
I/O. Java has many wonderful features; in particular, its treatment
of text I/O is powerful, general, and a royal pain to use (even with
the 1.5 Scanner class). I/O coding in ANY language tends to be
fiddly, with a high ratio of "tweak time" to important ideas.
Furthermore, I/O varies more from language to language than any other
common language feature, so anything students learn about I/O in this
language is only a slight benefit in other languages. BlueJ (and
DrJava and ProfessorJ) allows you to invoke a method on data
directly, and see the result directly, without writing any I/O code
at all. As the instructor, you can therefore postpone I/O until
whenever you think it fits naturally into your course.
--
Stephen Bloch
Math/CS Dept
Adelphi University
sbloch at adelphi.edu
More information about the bluej-discuss
mailing list