Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 9177 invoked from network); 31 Jan 2005 11:27:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 31 Jan 2005 11:27:32 -0000 Received: (qmail 75529 invoked by uid 500); 31 Jan 2005 11:27:29 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 75498 invoked by uid 500); 31 Jan 2005 11:27:29 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 75485 invoked by uid 99); 31 Jan 2005 11:27:28 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from out2.smtp.messagingengine.com (HELO out2.smtp.messagingengine.com) (66.111.4.26) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 31 Jan 2005 03:27:27 -0800 Received: from frontend2.messagingengine.com (frontend2.internal [10.202.2.151]) by frontend1.messagingengine.com (Postfix) with ESMTP id B5996C53686 for ; Mon, 31 Jan 2005 06:27:23 -0500 (EST) X-Sasl-enc: CfrKFMPv1WeuSLBNjbFWWQ 1107170842 Received: from [192.168.1.108] (adsl-70-241-81-6.dsl.hstntx.swbell.net [70.241.81.6]) by frontend2.messagingengine.com (Postfix) with ESMTP id 1F4F556F785 for ; Mon, 31 Jan 2005 06:27:19 -0500 (EST) Message-ID: <41FE1649.1010005@alumni.rice.edu> Date: Mon, 31 Jan 2005 05:28:09 -0600 From: "B. K. Oxley (binkley)" Organization: The Oxley Family User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [vfs] proposal: FileUtils References: <41F17027.30402@alumni.rice.edu> <41F17CF5.4060803@ops.co.at> <41F18708.1070709@alumni.rice.edu> <41FD61C6.9000706@alumni.rice.edu> <41FDDE5F.1070203@ops.co.at> In-Reply-To: <41FDDE5F.1070203@ops.co.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Mario Ivankovits wrote: > Where do you think to implement this FileOperation interface? I miss > the "source" fileobject -a s I said, I dont want to implement the > interface in the FileObject and thus thought about something like > this: > > DefaultFileOperations.get().copy(FileObject src, FileObject dest); I was going to pass the src in on construction of the operation object, but why? Using src as part of the parameter list seems just as good. > void save(final OutputStream newContents, final FileObject dest, > final boolean overwrite) throws FileSystemException; I have a strong distaste for using flags to control behavior in public methods. I find that it often leads to bugs when the flags are wrong, and it makes understanding the code more difficult. That is why I prefer explicitly named methods: void save(final OutputStream newContents, final FileObject dest) throws FileSystemException; void saveAndOverwrite(final OutputStream newContents, final FileObject dest) throws FileSystemException; How strong is your preference? > If overwrite=false and the destination exists the methods should use > "backup()" to create a backup of the destination file As an alternative, I took someone's suggestion of a policy object when I started coding a default implementation of the FileOperation interface, and let the policy object figure these things out. > Another thing we could discuss is the usage of save(InputStream, > ...). I renamed it to copy(InputStream, ...). I think if you do have > an InputStream you would like to copy its output to another file - in > opposite to save(OutputStream ...) where you do have the content of > the file in memory (a bufferedImage, ....) and would like to "save" > it. I like save() because it describes the operation most closely from the point of view of the caller ("Hey, save this file with these new contents!"). The reason I used InputStream everywhere was for genericness (is that a word?). I pictured usage like this: // copy(src, dst) in your snippet operations.save(src, otherFile.getInputStream()); operations.save(src, new ByteArrayInputStream(blobInMemory.toArray()); This sort of "negotiation" over interface is painful remotely. I'd rather do it with my programming pairmate while writing unit tests. :-) Cheers, --binkley --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org