Site hosted by Angelfire.com: Build your free website today!

My first OOP project : MARC file reader

Contents

Introduction

I wanted to try a project in Java. I have some experience with MARC records, so I set my sights on making a reader for a file of MARC bibliographic records with a catalog-like menu driven front end.

At the moment I'm discussing things in a pretty general way, because time is short. Presently the project has upwards of a thousand lines of source code so far, and I think I'm just getting started.

Classes

Entry -- Entry in an Index.
Index -- Contains entries and manages queries.
Inkey -- Keyboard input.
Marc -- Read individual records from file.
Menu -- Place to keep menus and assure common behavior.
Mn -- The main program.
Parse -- Take needed information from record.
ResultsPage -- Query results from a menu.

Sample Record

Here are two views of the same record. The first is the way the record looks to the computer. The second is a presentation that makes sense to a catalog librarian. The three digit integer in the second column is a code that says what kind of data resides in the rightmost, alphanumeric column. The third and fourth columns represent field length and offset from a fixed address respectively.

Unprocessed

01470cam 22003374a 4500001001300000003000600013005001700019008004100036010001700077040003000094020003500124042000800159043001200167050002300179049000900202245020400211260004300415300003800458440005100496500005600547504005100603650005800654650006300712650006500775700002200840700003100862710005400893856010200947938007101049994001201120¶ocm60321955 ¶OCoLC�.0�s2005 dcua bf 001 0 eng ¶ ‡a 2005013012¶ ‡aDLC‡cDLC‡dBAKER‡dVTT‡dMOA¶ ‡a1597260347 (pbk. : alk. paper)¶ ‡apcc¶ ‡an-usc--¶ 00‡aSB434.3‡b.T35 2005¶ ‡aMOAA¶ 04‡aThe Tallgrass restoration handbook :‡bfor prairies, savannas, and woodlands /‡cedited by Stephen Packard and Cornelia F. Mutel ; foreword by William R. Jordan III ; with a new preface by the editors.¶ ‡aWashington, DC :‡bIsland Press,‡c2005.¶ ‡axxxviii, 463 p. :‡bill. ;‡c23 cm.¶ 0‡aScience and practice of ecological restoration¶ ‡a"Society for Ecological Restoration International."¶ ‡aIncludes bibliographical references and index.¶ 0‡aPrairie plants‡zMiddle West‡vHandbooks, manuals, etc.¶ 0‡aPrairie restoration‡zMiddle West‡vHandbooks, manuals, etc.¶ 0‡aGrassland restoration‡zMiddle West‡vHandbooks, manuals, etc.¶ 1 ‡ aPackard, Stephen.¶ 1 ‡ aMutel, Cornelia Fleischer.¶ 2 ‡aSociety for Ecological Restoration International.¶ 41‡ 3Table of contents‡uhttp://www.loc.gov/catdir/toc/ecip0512/2005013012.html‡zView table of contents¶ ‡aBaker & Taylor‡bBKTY‡c37.50‡d37.50‡i1597260347‡n0006455372‡sactive¶ ‡aC0‡bMOA¶

Processed


## TAG LEN  OFSET  CONTENTS
-- --- ---- -----  ----------------------------------------------------------------
 0 LDR             01470cam  22003374a 4500
 1 001 0013 00000  ocm60321955 ¶
 2 003 0006 00013  OCoLC¶
 3 005 0017 00019  20060406090259.0¶
 4 008 0041 00036  050504s2005    dcua     bf   001 0 eng  ¶
 5 010 0017 00077    ‡a  2005013012¶
 6 040 0030 00094    ‡aDLC‡cDLC‡dBAKER‡dVTT‡dMOA¶
 7 020 0035 00124    ‡a1597260347 (pbk. : alk. paper)¶
 8 042 0008 00159    ‡apcc¶
 9 043 0012 00167    ‡an-usc--¶
10 050 0023 00179  00‡aSB434.3‡b.T35 2005¶
11 049 0009 00202    ‡aMOAA¶
12 245 0204 00211  04‡aThe Tallgrass restoration handbook :‡bfor prairies, sava
                   nnas, and woodlands /‡cedited by Stephen Packard and Corneli
                   a F. Mutel ; foreword by William R. Jordan III ; with a new 
                   preface by the editors.¶
13 260 0043 00415    ‡aWashington, DC :‡bIsland Press,‡c2005.¶
14 300 0038 00458    ‡axxxviii, 463 p. :‡bill. ;‡c23 cm.¶
15 440 0051 00496   0‡aScience and practice of ecological restoration¶
16 500 0056 00547    ‡a"Society for Ecological Restoration International."¶
17 504 0051 00603    ‡aIncludes bibliographical references and index.¶
18 650 0058 00654   0‡aPrairie plants‡zMiddle West‡vHandbooks, manuals, etc.¶
19 650 0063 00712   0‡aPrairie restoration‡zMiddle West‡vHandbooks, manuals, et
                   c.¶
20 650 0065 00775   0‡aGrassland restoration‡zMiddle WestvHandbooks, manuals, 
                   etc.¶
21 700 0022 00840  1 ‡aPackard, Stephen.¶
22 700 0031 00862  1 ‡aMutel, Cornelia Fleischer.¶
23 710 0054 00893  2 ‡aSociety for Ecological Restoration International.¶
24 856 0102 00947  41‡3Table of contents‡uhttp://www.loc.gov/catdir/toc/ecip051
                   2/2005013012.html‡zView table of contents¶
25 938 0071 01049    ‡aBaker & Taylor‡bBKTY‡c37.50‡d37.50‡i1597260347‡n00064553
                   72‡sactive¶
26 994 0012 01120    ‡aC0‡bMOA¶


Phases of Development

  1. Please compile
  2. Please run
  3. Please do something I intended
  4. Please generally work
  5. Notice errors
  6. Repair noticed errors
  7. Examine code for possible errors and exceptions
  8. Try to break code with selected cases
  9. Run all possible cases through all decision points
  10. Devise separate routines to check integrity of code
  11. Optimize performance using alternatives to code that already works
  12. Ask for input of someone who hopefully will not laugh at you on how to improve
Poor programming habits probably should deserve a proper twelve step group. No matter how hard you try, when you mess with your code you invariably go back to square one and wind up praying for a clean compile, and foaming at the mouth if it doesen't. Programming teaches humility like nothing else I have found.

A Little About Me

I have dabbled in programming for a fairly long time. I started writing spaghetti code in BASIC and FORTRAN on TTYs out of a games account in the '70s. I switched to structured programming in Turbo Pascal v. 2.0 on my own PC in the '80s. Along the way I picked up C and other languages. In the '90s I tried to take to C++ cold with nothing more than a manual and a comiler, but was overwhelmed. Java I started in the '00s. I have become more comfortable with C++ along the way, but can still go headlong into panic from it, probably because of my history with it.
About the only bad thing I have to say about OOP is that you need a project that gets big for it to become practical. While it is possible to do a "hello world" app in C++ or Java, it will look like a somewhat more longwinded version of code you could have written in C. It consequently took me a while to develop any appreciation of how to fruitfully butcher a process into component classes.

© Z. Tomory, 2006.

Resources

LC's MARC21 Concise Formats
NISO Standards -- Download Z39.2
Java Tutorial
Batch File Tutorial
Eck, David J. Introduction to programming using Java version 4.0 (2002)
Eversberg, B. What should catalogs do?
Eversberg, B. On the theory of library catalogs and search engines