On Monday 05 January 2004 11:17 am, Daniel F. Savarese wrote: > > I disagree slightly (it's actually agreement, but with a naming > difference) and have some suggested code changes (I can make them if > there's agreement). First, the getFileList methods should be > named listFiles() as that's what they're replacing. We can > deprecate the old listFile methods that take FTPFileListParser > arguments and reimplement listFiles() and listFiles(String pathname) in > terms of the new stuff using autodection (removing > getFileList(String parserKey) since the signatures conflict and the > common case will be to use autodetection anyway). Second, we shouldn't > create an FTPFileListParserFactory on every call to getFileList. Instead, > FTPClient should maintain a reference to an FTPFileEntryParserFactory. > This reference should be configurable by the user with a setter > method. That allows API users to change the factory implementation. > Third, we shouldn't set the default factory based on a property. > Once we add the setter method, there is no need for the property. > In general, it's better to let applications handle their configuration > through properties and leave the library free of dependencies on property > values. Which factory to use is an application-level decision (e.g., > an ant task can define a property that changes the factory for its > purposes), not a library-level decision.
I have no disagreement with any of this. In fact the getFileList(String parserKey) bothered me as much as it bothered you. However, since I continue to have free time, I'd just as soon fix this stuff myself. Just to verify that I have understood all your points: 1) deprecate listFiles() methods that take a FileEntryParser parameter. 2) reimplement listFiles() to do what getFileList(null) now does. 3) reimplement listFiles(String pathname) to do what getFileList(null, pathname) now does. 4) rename getFileList(String parserKey, String pathname) to listFiles(String parserKey, String pathname). Even though autodetection will be the primary use case, it already will not work for every system (see EnterpriseUnix) and there must be some way around it. This is that way. 5) don't use properties to select the parser factory in our library. Instead, add a property and a setter method. Initialize in the library to use the default. Have I missed anything? One problem remains. getFileList() throws a new exception: ParserInitializationException. If we simply rename these methods to listFiles() we will break lots of code. That was my primary reason for giving them a different name. One way around this would be to make ParserInitializationException a RuntimeException. That makes sense, as the error is not recoverable and is always due to a programming error - passing in a key that the system cannot parse, specifying a class that has not been made available. Would you agree? (Parenthetical note: this distinction has always seemed a little confusing to me and I think I finally understand why: the name. It should not have been named "RuntimeException". All exceptions occur at runtime, both checked, recoverable exceptions and those caused by programming errors. Joshua Bloch, in Effective Java lays this out clearly enough. If it was called PreconditionViolationException or some such, it would be much clearer. As it is, I've seen too many instance of exceptions being made RuntimeExceptions simply because the programmer thought that propagating it up though the call stack was too difficult. But I don't think that's the case here. This is legitimately a RuntimeException). > > Jeffrey Brekke writes: > >list parsers, and/or implementing the existing list parsers with an > >implementation that uses the entry parsers. That way we are parsing > >with one implementation? > > That should be probably be our first step toward deprecation so the > parsers behave consistently. In the 1.2 release we can deprecate the > old listFiles methods presuming we agree to keep the method name for > the files (the class method names currently mirror as closely as possible > the FTP commands they implement). We're stuck by the Commons > versioning/release rules regarding when we can remove the old stuff. > It has to stay in all of the 1.x releases. Otherwise, I'd say that in > 1.2 we announce that in 1.3 FTPFileListParserImpl will no longer > implement FTPFileListParser and deprecate the interface in 1.2, removing > it in 1.4 along with the old listFiles() methods. We'll just have to > wait until 2.0. I just tested it, and if we deprecate FTPFileListParser > now, it only affects the javadocs for FTPFileListParser. I think we > can live with any compiler warnings saying that you're using a > deprecated interface as long as we document this. With a J2SE 1.4 > compile, you only get warnings for the listFiles methods, > DefaultFTPFileLister (which we also need to deprecate), and > FTPFileListParserImpl, but none of the FTPFileListParserImpl subclasses. > So I propose deprecation in 1.2 and removal in 2.0. Agree here too, although the idea that FTPFileListParserImpl will no longer implement FTPFileListParser is extremely odd. I suggest we might want rename this class now to FTPFileEntryParserImpl. As it's abstract, I don't think we'd be impacting anyone. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
