S6423: Java User Experience: Confessions of and old COBOL Programmer
SHARE Technical Conference, August 20, 1998
Abstract:
An old COBOL programmer will share his experiences
learning the Java language. Over the past year the speaker has
programmed in Java using the Sun compiler, the Microsoft Visual
Java++ integrated development environment, and VisualAge for Java
from IBM.
You are welcome to check the author's website,
www.jsrsys.com, for a preview of his presentation as it
is being developed, including code examples.
Steve Ryder, Senior Director
JSR Systems (SHARE Code: JSR)
2 Margranita Crescent
Austin, Texas 78703-1717
sryder@jsrsys.com
www.jsrsys.com
512.917.0823
The speaker has been developing COBOL
code since 1968. Other "languages" he has used include:
Univac 1050 assembler, IBM 360 assembler, CDC Cyber assembler,
AutoCoder, Algol, PL/I, Fortran, Pascal, C, C++, Java, and HTML!
Clients for whom the speaker has developed
code include:
The University of Texas at Austin
1965-1966
Texas Education Agency
1966-1995
Houston Ind. School District
1975-1981
Conroe Ind. School District
1980-1993
United States Navy
1966-1994
Capitol Appraisal Group, Inc.
1981-1998
The development "environments" I
tried included:
www.sun.com JDK 1.02 download.
Microsoft Visual Java++
NetRexx
www.javasoft.com JDK 1.1
Visual Age for Java Professional
I began my adventure in Java by studying
"Teach Yourself Java in 21 Days" by Laura Lemay.
I highly recommend this book, and this approach. The particular
book came with a CD-ROM version of Sun's JDK 1.02, and all the
examples were also on the CD-ROM. After working thru most of
the examples in this book, I decided to get Microsoft Visual
Java++. This IDE would be ideal if you are using Microsoft's
C++ IDE. The jsrDump utility actually began
by using the applet wizard, however I found the code generated
by the wizard to be overly complex, and eventually whittled
most of it out of the program.
I installed the NetRexx to Java utility,
hoping at I could code some simple NetRexx programs, then
inspect the generated Java code. I quickly learned that
the generated Java code was not meant to be read by humans, and
that was the end of that adventure.
I downloaded the JDK 1.1 from javasoft
mainly for the documentation. Since I have been writing
code since 1964, I knew what I wanted to do, I just did not know
the class names, properties, and methods.
I was quite impressed by the two day
Visual Age for Java tutorial I took at SHARE a year ago.
I purchased the software, and have worked thru about half the
examples in their excellent and very slim "Getting
Started" book. I had hoped to be farther along in time
for this presentation. However, things have been very busy back
at the ranch! Yes, there is lots of demand for old COBOL programmers,
though I expect we will be doing most of our new development using
the Visual Age for Java Enterprise edition next year. Of course
Y2K updates could delay that estimate.
Here is my own "hybrid IDE"
using Microsoft Visual Java++ components, with DOS command J*.BAT
files, and the Programmer's File Editor (PFE) freeware
which I discovered thru PC World's Tipworld.
jdoc.txt -- Document JSR Systems
"IDE"
** j.bat follows: rem j.bat -- change directory to
java rem jc.bat - compile java rem jcr.bat compile and run java rem je.bat - edit java with pfe rem jj.bat - exec java class cd \jsr\java
I have organized my directory structure so
that I develop my Java code in the jsr/java directory.
Completed source is placed in the jsr/java/source
directory, and completed class files are placed in jsr/java/bin,
which is included in my CLASSPATH list. I have found the default
error messages to be sufficient to determine any errors, and have
not really had to do much with the -debug options.
Now is the time to demonstrate some
of my utilities. If you wish to run these on your own system
at home, feel free to download the jsrClass.zip, and the
jsrJava.zip files from my website, www.jsrsys.com/jsrsys/java.
You are free to use these programs as long as you abide by the
www.jsrsys.com/copyright conditions.
Dump.bat (invokes)
jsrDump. Demonstrate use from command line, from the SendTo
menu, and using file dialog.
JsrEdit with
jsrSHARE.txt "command" file.
LogHTM and
logSplit with access.bat and client.bat.
Coding Issues
Now you have seen some of the types of applications
you can easily do in Java. Let's look at the code to answer the
question, how can you do that?
Working Storage vs. Scope. [jsrDump: 30-33]
30: static final int maxChar = 78; 31: static final int maxLine
= 10;
32: static final String scaleLine =
33: ....+....1....+....2....+....3/5....+....6....+....7....+678";
Checking for valid command line input (PARM )
[jsrList: 24-29]
24: if (args.length < 2) 25: { debug.Display("jsrList--must
contain two arguments:"); 26: debug.Display("---------arg
1: file suffix (i.e., java)"); 27: debug.Display("---------arg
2: target file for output."); 28: return; 29: }
Display w/o sliding off screen [jsrDebug:
36-39]
36: if (nLines > maxScreen) 37: Accept(displayString); 38: else
39: System.out.println(displayString);
Accept will pause if screen is full.
If user enters "q", all further Display requests will
be ignored.
Pad "integer" string for alignment
[logHTM: 120-123]
120: Integer intCount = new Integer(htmCount[i]);
: // convert integer
to String 121: String strCount = intCount.toString(); 122: while (strCount.length()
< 10) strCount = " "+strCount;
: // pad
to 10 bytes 123: countArray[i] = strCount
+" accesses to: "+htmName[i];
"=" is an assignment operator,
for comparisons use "==" [jsrEdit: 181]
181: if (endFrom == '=')
String comparisons use method "stringname.equals"
[jsrEdit: 171]
171: if (to.equals("*delete*")
&& where != -1)
Note also that "&&"
is logical AND, "||" is logical OR, "!" is
NOT.
Strings have many rich methods [jsrEdit:
159, 162, 167, 178]
159: int lenFrom = from.length(); 162: char endFrom = from.charAt(lenFrom-1); 167: where = oldString.indexOf(from); 178: newSB = newSB+oldString.substring(last,where)+to;
All parameters default to passing by value
rather than address. This prevents "called method" from
modifying input parameters. One exception to this is arrays. Thus
if you want to be able to return more than one value from a method,
you could pass arrays with one occurrence (arrayname[]), which
can then be modified.