Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

JVM Languages

A Year 2000 Tool Suite


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


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.