Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review code style, refactor functions into namespaces #3

Open
dimo414 opened this issue Dec 10, 2015 · 3 comments
Open

Review code style, refactor functions into namespaces #3

dimo414 opened this issue Dec 10, 2015 · 3 comments
Milestone

Comments

@dimo414
Copy link
Owner

dimo414 commented Dec 10, 2015

Original report by Michael Diamond (Bitbucket: dimo414).


Reference https://google.github.io/styleguide/shell.xml

The Google Style Guide suggests using :: to delimit function namespaces, but that prevents tab-completion¹ (perhaps that's an advantage?). . seems to be a common choice which does enable tab-completion.

¹ See Bash FAQ E13 and https://stackoverflow.com/a/12495727

@dimo414
Copy link
Owner Author

dimo414 commented Aug 22, 2017

Original comment by Michael Diamond (Bitbucket: dimo414).


There are really a couple different namespaces to support:

  • __pgem::: truly private, used only internally by ProfileGem (e.g. the functions in privateGemFunctions.sh and other helpers)
  • _pgem_: Utility functions intended to be used by gems
  • pgem_: User-facing functions intended to be called interactively

@dimo414
Copy link
Owner Author

dimo414 commented Nov 3, 2017

Original comment by Michael Diamond (Bitbucket: dimo414).


Gems should also have standard namespaces:

  • __foo_gem:: for foo.gem's private fields
  • _foo_gem_ for fields that will be accessed by other gems
  • User-facing functions and variables should not be namespaced

@dimo414
Copy link
Owner Author

dimo414 commented Jun 4, 2018

Original comment by Michael Diamond (Bitbucket: dimo414).


Different plan, along the lines of bash-cache:

  • pg::_foo for private helper functions
  • pg::foo for non-interactive functions such as those used by gems
  • pgem_foo for user-facing functions

Gems should similarly use a bar:: namespace (where "bar" is the name of the gem) for non-user-facing functions.

NB pg is a standard Unix command, so pg shouldn't be used directly.

@dimo414 dimo414 added this to the v1.0 milestone Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant