A Year 2000 Tool Suite

Dev presents a Year 2000 toolset written in Java, consisting of a scanning tool that examines source code for date-related areas, and a data ager tool that lets you manipulate existing production data.



May 01, 1998
URL:http://www.drdobbs.com/jvm/a-year-2000-tool-suite/184410552

A Year 2000 Tool Suite

Dev is a consultant with Visa International's Year 2000 project working on desktop and midrange computers. He can be contacted at [email protected].


Contrary to popular belief, the Year 2000 problem poses a threat not only to mainframe systems, but to desktop and client-server systems. Many of these problems derive from prebuilt routines that are not Year 2000 compliant and are regularly used with the current offering of visual and RAD desktop development tools. Another problem unique to client-server systems is making sure every segment of the application that manipulates data is compliant.

To address these problems, programmers need both tools that scan source code for date-related data structures and functions, and those that create test data from existing production data. In this article, I'll present two such tools. The scanning tool examines an application's source code for date-related areas and offers a preliminary analysis of the target application. The data ager tool lets you manipulate existing production data to create a set of test data. Both the date scanner and data ager (written in Java 1.1) are available electronically; see "Resource Center," page 3.

Date Scanning

The scanner identifies areas in the source code that match a dictionary of date-related words -- words often used by programmers to portray dates. The scanner then generates an HTML page containing the source code excerpts with impacted areas hypertext linked to a date-dictionary URL. Not all of the source code in the report are true Year 2000 trouble spots, but it is better to err on the side of caution.

Developers often use real-world terms to describe date variables and functions, so the scanner looks for words like "date," "age," and "yy-mm." Example 1 shows a list of common "real-world" words.

However, as Example 2 illustrates, some developers use words that have no bearing on what they are supposed to represent. Examples of such obscure code are common, and only the developer knows why he used such deviant names to perform date arithmetic or store dates. To guarantee better analysis, the scanner should include programming language reserved words that are used to declare user defined types and dates -- "type," "struct," "class," and so forth.

To avoid identifying nondate trivia as Year 2000 trouble spots (such as "message" which contains "age," and "update" which contains "date"), I include a dictionary of words to ignore. Example 3 contains a list of some nondate-related words that can be potentially misidentified. If the scanned word is in this "ignored words" dictionary, the scanner disregards the word.

Figure 1 presents an abridged description of the JavaScan class. The complete Java source code (available electronically) is well documented. Objects derived from standard Java classes in java.io (File, FileInputStream, StringBuffer, and the like) and java.awt (TextArea, Button, and so on) are used in this class. This applet/application can run on older browsers supporting JDK 1.0.x. To recompile the package under older compilers of the JDK 1.0.x era, you must use the statements that are commented as belonging to JDK 1.0.x.

When the applet/application is loaded, users acknowledge a disclaimer by clicking the Agree button. The text field at the bottom of the applet/application window now has the focus. You must type the valid path and name of the file you want to examine, and click the Open button. The source-code file will be loaded and scanned, and a report is created in the file output.html. You can click on the applet hot-spot to view this page, or you can view the page from your web browser.

The scanning tool scans only a single source file. One possible enhancement to this application would be to scan multiple source files, generate statistics on total lines of code and date-related fields, and output the report to multiple HTML pages.

Aging the Data

There are a number of ways of generating test data, one of which is to "age" current production data. By aging, I mean that all dates are increased or decreased by a specified number of days or years. Each date is increased or decreased by the same amount, maintaining the data's referential integrity between dates. Figure 2 lists the classes used by the prototype for the ager project.

To use the ager, you dump your data containing dates into a text file. The ager tool allows you to specify where the date lies in the text file rows, and the format of the date. The tool also lets you specify the format in which the date will be rewritten (see Figure 3), after which you can reload the data back to where they came from.

I designed this application differently from the date scanner. It is not downward compatible to JDK 1.0, and it uses the new features of AWT and the language enhancements of JDK 1.1. I implemented it with Borland's JBuilder 1.0, using Borland's extensions to the AWT classes. These extensions can easily be modified to suit other compilers.

You enter the name of the text data file (complete path information) and click the Open button. Twenty records from the data file (or fewer if the data file is smaller) are loaded as a sample in the TextArea component. You then enter the record length to correctly align the 20 records.

You then select the year component and enter the starting point and length in the first row of data in the TextArea to mark the year portion of the date. The portions you define are highlighted in the TextArea, reconfirming your entries. A button is provided to place the entry in a list for later use. Likewise, you must mark the date, month, and the full date field in the same row.

You then enter the format into the preset date field. The format could be any combination of M, d, y, and separators. Notice the "M" is in uppercase. After all the selections are complete, users click the Age button, and the aged data is saved as "c:\out.txt". A sample 20 rows are displayed back in the TextArea for users to confirm whether the results are what they wanted. If the results are erroneous, changing the parameters and rerunning again will achieve the desired output.

This aging tool can alter only one date field at a time. It also can address only one table at a time in a database. The tool is incapable of addressing date-derived fields like invoice numbers or purchase order numbers that may have portions of dates embedded in them.

DDJ


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

age
ccyy
current
date
ddmmyy
dmy
leap
mdy
min
mmm-dd
now
period
time
tm
tomorrow
year
ymd
yy-mm
mos
interval
qtr

Example 1: Common "real-world" words.


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

A Year 2000 Tool Suite

By Dev Bhattacharyya

Dr. Dobb's Journal May 1998

(a) 
struct dRecord 
{
    int xx;
    int yy;
    int zz;
};

(b)
int dTemp, mTemp, yTemp;

(c)
Dim dTemp As Variant

Example 2: Words that are not suggestive of what they are supposed to represent.


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

A Year 2000 Tool Suite

By Dev Bhattacharyya

Dr. Dobb's Journal May 1998

breadth
message
validate
page
bitmap
femin
image
tmp
update
know
itemindex
html
idyes
agent
language
minim
percentage
manage
flagerror
section
centimeter

Example 3: Nondate-related words that can be misidentified.


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

A Year 2000 Tool Suite

By Dev Bhattacharyya

Dr. Dobb's Journal May 1998

Figure 1: Abridged description of the JavaScan class.


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

A Year 2000 Tool Suite

By Dev Bhattacharyya

Dr. Dobb's Journal May 1998

Figure 2: Class representations used by the prototype for the ager.


Copyright © 1998, Dr. Dobb's Journal

A Year 2000 Tool Suite

A Year 2000 Tool Suite

By Dev Bhattacharyya

Dr. Dobb's Journal May 1998

Figure 3: Running the Data Ager tool.


Copyright © 1998, Dr. Dobb's Journal

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.