|
Explanation:
|
+-------------+----------------+-------------+-------+ | ID | Name | Address | level | +-------------+----------------+-------------+-------+ 6 chars 20 chars 20 chars 4 chars |
The new record structure is:
class StudentRecord { String ID; // 6 chars String name; // 20 chars String address; // 20 chars String level; // 4 chars } |
|
How to run the program:
|
Student file content: 123, John Smith, North Street 12, 4 234, James Bond, West Street 89, 3 333, George, East Ln 21, 2 444, Peter Pan, Never Land, 3 |
This is how the records are stored:
0000000 1 2 3 \0 \0 \0 J o h n S m i t h 0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 N o r t h 0000040 S t r e e t 1 2 \0 \0 \0 \0 \0 4 \0 0000060 \0 \0 2 3 4 \0 \0 \0 J a m e s B o 0000100 n d \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 W e s t 0000120 S t r e e t 8 9 \0 \0 \0 \0 \0 \0 0000140 3 \0 \0 \0 3 3 3 \0 \0 \0 G e o r g e 0000160 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 E a 0000200 s t L n 2 1 \0 \0 \0 \0 \0 \0 \0 \0 0000220 \0 \0 2 \0 \0 \0 4 4 4 \0 \0 \0 P e t e 0000240 r P a n \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 0000260 N e v e r L a n d \0 \0 \0 \0 \0 \0 0000300 \0 \0 \0 \0 3 \0 \0 \0 |
When you use the old program to do lookup on the student-file, you will get:
cheung@aruba> java LookupStuFile // use the old program !!! Student file content: 123J, SmithNort, 2 !!!!! 4, James Bond, eet 89, 333Geo, st L n 21, 2444, |
The old program cannot access the fields correctly because their position have moved !!!
|
Conclusion:
|
|
|
Example:
|
|
When we change the data format, we will need to change all programs that access the data and re-compile these programs.
Needless to say that this is a system maintainance nightmare