app-dirs-rs icon indicating copy to clipboard operation
app-dirs-rs copied to clipboard

Rename functions

Open andybarron opened this issue 8 years ago • 1 comments

They're kind of terrible, and I think I have a better scheme now:

  • app_dir -> ensure_app_dir
  • get_app_dir -> compute_app_dir

Discussion is very welcome...

andybarron avatar Feb 04 '17 18:02 andybarron

Thank you for opening up this discussion! I'm using your crate, and really satisfied with the functionality. I'd have a bit of input in this, but what it has isn't that bad I'd say - might be slightly confusing with app_dir defaulting to creating something, but then again that is a reasonable default.

I'm not at all sure what the best names would be, but have you seen https://github.com/rust-lang/rfcs/blob/master/text/0356-no-module-prefixes.md? It's a guideline on things in the standard library, but I think it might be a good thing to apply to crates as well.

The ensure_app_dir and compute_app_dir definitely seem better than the current names to me - I certainly can't think of anything better at the moment, but part of me does want to have the methods without 'app' in them.

If I was to come up with names from scratch, I would probably do something like the following (I don't think these would be good to change to now, just giving some input to the discussion of possibilities):

  • get_data_root -> data_root
  • data_root -> create_data_root
  • get_app_root -> dir
  • app_root -> create_dir
  • get_app_dir -> sub_dir
  • app_dir -> create_sub_dir

create_ slightly mirrors what std does with File::create (create a file only if it does not exist).

daboross avatar Jun 08 '17 04:06 daboross