commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torsten Curdt" <tcu...@apache.org>
Subject Re: [compress] Draft 6
Date Fri, 12 May 2006 16:09:18 GMT
> the small problem with that or any factory is the use of a String to
> request a behavior means the compiler cannot know for sure if that
> code will work.

And this is a problem why?

I think it would be great to be able to just pass in a file object
into the factory that will look e.g. at the file extension (or even
header) and figure out what archiver to use. Otherwise you *always*
have to implement that part yourself.

Checking the result of a factory for null or throwing an exception is
common practise and I cannot really see real benefit of the
compile-time check here.
There are probably always going to be archivers that compress is not
going to support. So the factory *cannot* always return an instance
...unless you do all the checking

if (".zip".equals(extension)) -> ArchiveType.ZIP.newInstance();
if (".rar".equals(extension)) -> ArchiveType.RAR.newInstance();
...

in you code - which is cumbersome IMO.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message