Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 23
    Actually I have no clue what false means in the file.saveWithEncryption example. Does it mean that it will save without encryption? If so, why in the world would the method have "with encryption" right in the name? I could understand have a method like save(boolean withEncryption), but when I see file.save(false), it is not at all obvious at a glance that the parameter indicates that it would be with or without encryption. I think, in fact, this makes James Youngman's first point, about using an enum. Commented May 9, 2012 at 23:20
  • 6
    An alternative hypothesis is that false means, don't overwirte any existing file of the same name. Contrived example I know, but to be sure you'd need to check the documentation (or code) for the function. Commented May 9, 2012 at 23:34
  • 7
    A method named saveWithEncryption that sometimes doesn't save with encryption is a bug. It should possiby be file.encrypt().save(), or like Javas new EncryptingOutputStream(new FileOutputStream(...)).write(file). Commented May 10, 2012 at 14:09
  • 3
    Actually, code that does something else than what it says doesn't work, and is thus a bug. It does not fly to make a method named saveWithEncryption(boolean) that sometimes saves without encryption, just like it doesn't fly to make a saveWithoutEncryption(boolean) that sometimes saves with encryption. Commented May 10, 2012 at 15:10
  • 2
    The method is bad, because there is obviously "doubt about the meaning of 'false' here". Anyway, i would never write a method like that in the first place. Saving and encrypting are separate actions, and a method should do one thing and do it well. See my earlier comments for better examples how to do it. Commented May 10, 2012 at 17:27