stacycurl / pimpathon

Adds useful methods to scala & java classes.
Apache License 2.0
35 stars 9 forks source link

File.write not append by default #184

Closed fommil closed 9 years ago

fommil commented 9 years ago

I was surprised that append=true by default in this method. I'd be happy for an API breaking change to change the default to false.

stacycurl commented 9 years ago

I'm happy to change (I don't know of any other project using pimpathon !) but append=false sounds more dangerous, i.e lose data by default. Why were you surprised ? is it more common to default to false ?

Counterproposal: Leave the default as 'true' but expose it via another FileUtils field:

case class FileUtils ( suffix: String = ".tmp", prefix: String = "temp", append: Boolean = true , private val currentTime: () => Long = () => System.currentTimeMillis() ) ...

You could then do this:

package ensime { val file = pimpathon.file.copy(append = false) }

elsewhere

import ensime.file._

Would that be workable & non-cumbersome, if not then I'll change the default (and expose it via a field so other can set it to true).

Cheers.

On 4 February 2015 at 14:39, Sam Halliday notifications@github.com wrote:

I was surprised that append=true by default in this method. I'd be happy for an API breaking change to change the default to false.

— Reply to this email directly or view it on GitHub https://github.com/stacycurl/pimpathon/issues/184.

Stacy

fommil commented 9 years ago

I think the precedent set by guava and apache commons with their File.write conveniences is to append=false by default.

stacycurl commented 9 years ago

Ok, I'll change it but expose it via another field on FileUtils.

On 4 February 2015 at 20:50, Sam Halliday notifications@github.com wrote:

I think the precedent set by guava and apache commons with their File.write conveniences is to append=false by default.

— Reply to this email directly or view it on GitHub https://github.com/stacycurl/pimpathon/issues/184#issuecomment-72936147.

Stacy

fommil commented 9 years ago

cool

stacycurl commented 9 years ago

I think 'def outputStream(append: Boolean = true)' should be changed too, and therefore that 'def outputStream = outputStream(false)' should be dropped

On 4 February 2015 at 21:03, Sam Halliday notifications@github.com wrote:

cool

— Reply to this email directly or view it on GitHub https://github.com/stacycurl/pimpathon/issues/184#issuecomment-72938875.

Stacy