Design question

General discussion on the JZOS batch launcher and toolkit
Post Reply
john.mckown
Posts: 48
Joined: Tue Jun 12, 2007 2:46 pm

Design question

Post by john.mckown »

This is not about JZOS in particular, but about how to design a Java program. I am writing a program which processes a sequential file. Java does not have anything like a COBOL WORKING-STORAGE section or a C/C++ struct to map a buffer into a record. So I am wring a Java CLASS which contains the variables in the record.

I have two choices as to how to proceed. The first is to parse the record data into the variables in the the CLASS constructor. The user could then directly access the variables (which would be PUBLIC and, if read-only, FINAL).

The second choice is to keep the entire record in a PRIVATE byte array. Then have a bunch of "get" methods which only decode the value for a particular variable when it is accessed.

I like this second because it defers the CPU utilization of decoding the record into variables to when the user actually references a variable. The minus is the CPU is higher per access, if the user ends up accessing most of the variables.

I guess the third choice is to have two constructors. One which keeps the record in a PRIVATE byte array for later decoding and a second with decodes when the CLASS is constructed. This second constructor would set a BOOLEAN to indicate that the variables have been decoded and to use the PRIVATE variable in the CLASS which corresponds to the "get" method.
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

John,

We have recently been working with IBM to address this very problem. The work is still "in progress", but some of it should be released this month into a new alphaWorks version of JZOS.

This support that should be available this month in "JZOS 2.1.1 alphaWorks" includes:

- a complete set of byte-array type-converters for Cobol and Assembler "field" types.
- a generator that takes, for now, assembler DSECTS and generates a Java record class to map the data. As in your design, a single byte array will store the bytes, but instance variables will also "cache" field values as they are converted.
- examples

Regards,
Kirk Wolf
Post Reply