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

Codify guidelines for "helper" functions. #6164

Open
LarryOsterman opened this issue Nov 1, 2024 · 3 comments
Open

Codify guidelines for "helper" functions. #6164

LarryOsterman opened this issue Nov 1, 2024 · 3 comments
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team

Comments

@LarryOsterman
Copy link
Member

Currently we have no class naming guidelines for "helper" classes.

Examples include:

  • Azure::Core::Uuid
  • Azure::Core::_internal::HttpShared
  • Azure::Core::UserAgentGenerator
  • Azure::Core::StringExtensions
  • GetEnvHelper
  • Azure::Security::Attestation::_detail::JsonHelpers
  • Azure::Core::Credentials::_detail::AuthorizationChallengeHelper
  • Azure::Core::Credentials::_internal::AuthorizationChallengeParser

Codify the use of the suffix naming so that we are consistent within the Azure SDK.

Extremely preliminary thoughts:

Type names without suffixes should represent concrete types that can be stored in another types. Examples include:

  • Azure::Core::Uuid
  • Azure::DateTime

These types should contain non-static methods because they represent a concrete idea.

Static-only helper types should always have a suffix.

Known suffixes include:

  • Helpers - this is used for types which contain convenience methods to "help" in a task (Generating certain HTTP headers for example)
  • Extensions - this is used for types which extend an existing type.
  • Parser - static methods used to help parse types (this one's a bit weird - a UrlParser for instance could also be a factory for Urls)

Related guideline:

  • Static-only types must have a private constructor and destructor to prevent accidental instantiation.
@github-actions github-actions bot added Azure.Core Client This issue points to a problem in the data-plane of the library. labels Nov 1, 2024
Copy link

github-actions bot commented Nov 1, 2024

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 1, 2024
@ahsonkhan
Copy link
Member

ahsonkhan commented Nov 4, 2024

Is the intent to codify this guideline meant for public surface area that we can't change/modify, or for implementation detail?

@LarryOsterman
Copy link
Member Author

Is the intent to codify this guideline meant for public surface area that we can't change/modify, or for implementation detail?

This guideline is meant for the Azure SDK for C++.

It applies to all scenarios in which we might be defining types.

For instance, when considering whether a type is a helper type or not, by definition helper types should not define concrete constructs - for example, Uuid, ETag, and UserAgent - by their name, these types are values and thus can be expected to be used as a variable or class member. But UserAgentGenerator/UserAgentBuilder/UserAgentHelper are names which make it clear that they are NOT expected to be used as a variable.

Note that we could also consider defining these functions as free functions within a namespace, but that has its own set of challenges (I'm personally not a fan of free functions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

No branches or pull requests

3 participants