commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From __matthewHawthorne <>
Subject [io] thoughts on FileUtils methods while improving test coverage
Date Tue, 26 Aug 2003 23:21:36 GMT
Most of these comments are directed at Jeremias... but if anyone else is
interested, please let me know your thoughts.

I ran the clover report in Maven to get a better idea of test coverage.  
is a lot of code that is not being executed, and I plan on writing a lot of
tests to help fix that.

The first class I'm working on is FileUtils, and I have a few notes and

    void waitFor(String, int)
        - You made a note asking if this method makes sense.  I think 
this could be
        useful in some circumstances.  It's difficult to test though.

    String[] getFilesFromExtension(String directory, String[] extensions)
        - You made a note saying that this should be rewritten using the 
        package.  I agree, but also believe that this method should be 
simplified a little.
        how about something like:

            File[] getFiles(File directory, FileFilter[] filters)

        If necessary, we could write a small wrapper around this method 
which could
        provide the functionality of the original.

        This method also provides some undocumented behavior, such as 
excluding all
        "CVS" directories.  This is useful, but I think that the method 
is trying to
        do too much... it seems too specific for a *Utils class.  I 
would think
        that something like that should be in a CvsFileUtils class.

    File toFile(URL)
        - We've talked a little about this.  There seems to be such a 
large room for
        error in these types of conversions, that I don't like providing 
        My vote is to eliminate this method.

    I think that the following methods don't add a lot of value, and 
should be

        void fileDelete(String fileName)
        boolean fileExists(String fileName)
        String     fileRead(String fileName)
        void fileWrite(String fileName, String data)
        boolean isFileNewer(File file, Date date)

Here is my rationale for deleting some of the aforementioned methods: in a
package like [io], there seem to be endless convenience methods that we can
provide, so I think we should choose our battles wisely.  Methods that 
save a
user 1 line of code aren't worth it.  We shouldn't be providing methods 
that will
allow users to remove the import from their classes, we 
should be
trying to replace all of the things that they do with the File objects.

Redundant stream reading/writing, filename parsing, cleaning 
directories, these
are useful things that we are providing.

I'm starting to think that any methods that don't take a as 
a parameter
should be removed.  A lot of the parsing methods are useful and can be 
put in
the new FilenameUtils class.

Let me know what you think.

View raw message