Chris Uppal wrote:
{snip}
(Corrected version, I really need ro read my words before sending them.)
Sorry my response is so delayed, I've been heads down in project without
time to play. At times the theoretical must make room for the practical.
All your points are well taking, and in keeping with OOP and Java
principles. Perhaps this is where my issue derives -- I have
fundamental disagreements with OOP and the direction Java is taking. As
a c language programmer from K&R forward, I love the simplicity of that
language, believing less is more.
With Java, the "API" is so large, and growing, it is approaching the
point where effective use will be diminished because of its immense
size. So with that said, I shall address your following points.
If an API is defined with abilities roughly like the Zip utilities (i.e. making
best efforts to retrieve data, even if it means falling back to another access
method; pretending that it is possible to replace one file in a Zip file as a
single operation, and so on) then I think that should be a higher-level API,
and separate from the relatively low-level APIs that exist.
While I agree on principle with this, utilities build up, from the
lower, more simpler components to higher, more advanced functionality.
Since opening a file is, IMHO, the simplest of operations, a higher
level utility to "repair" a zip file would still need to open that same
zip file. (Remember that the zip file in question is still valid, just
without one valid structure, the TOC.) However. ZipFile cannot be used
to open this file, so a complete replacement of ZipFile is needed, not
an extension of ZipFile.
As far as I can
see, the current low-level APIs are just about sufficient to allow Sun to
create a higher level one on top of them[*].
The functionality I added in myZipFile class, using InputStream and
ZipStream, have the ability to 1) differentiate between an invalid zip
file, for example myZipFile.java, and one such as the OPs zip file
missing the TOC, and 2) simulate the functionality of ZipFile, less
direct access of course (which I intend to add in the future). The
replacement is functional, and demonstrates my point that the native
method ZipFile.open() could do the same, thus making ZipFile more
useful, not less. (Look mom, no utilities!)
Perhaps you are right and some
such API should be added to the existing stuff (I can certainly think of uses
for it), but it should be separate from, and in addition to, the current stuff.
I would hate to see it all rolled-up into one big ball where I didn't have
control of (and perhaps didn't even know) what the code is doing.
I see no loss of control because ZipFile.open() can detect a truly bad
zip file, or open the OPs limited zip file. And, by extending ZipFile,
the OOP/Java way, to create your higher level utility, control is once
again restored -- you could fail to open a zip file that does not
contain a valid TOC for instance, by throwing an exception.
It remains my opinion that as a "user" of the Java language, I have the
right to "demand" reasonable behavior from the language developers, just
like my customers/users demand reasonable behavior from my work.
Perhaps I am just getting too picky in my old age, but when I began in
software development, the concept of open source, community developed
OSes and languages was just that -- a concept many of us desired. Now
that these concepts are being realized, I wish to push the envelope
further, by raising the awareness of language developers that their
"customers" are we that use the fruits of their labor.
joseph