Skip to content

Conversation

marcoscaceres
Copy link
Contributor

@marcoscaceres marcoscaceres commented Oct 3, 2025

This pull request makes a minor update to the documentation for using strings as constant values. The change clarifies that abbreviations should be avoided, as they can make code harder to read.

Closes #599


Preview | Diff

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates documentation to provide clearer guidance on string and enum naming conventions. The change adds explicit advice to avoid abbreviations when using strings as constants or enumerated values, emphasizing code readability.

  • Added guidance to avoid abbreviations in string constants and enums

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

index.bs Outdated

Strings make it easier for developers to inspect values
and read code that uses those values.
As such, avoid abbreviations as they can make code harder to read.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not just cite https://w3ctag.github.io/design-principles/#naming-is-hard ?

If that doesn't mention abbreviation, then it can be updated to do that.


Strings make it easier for developers to inspect values
and read code that uses those values.
and read code that uses those values (see [[#naming-is-hard]]).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this fits better in the first paragraph:

Suggested change
and read code that uses those values (see [[#naming-is-hard]]).
and read code that uses those values.


<h3 id="string-constants">Use strings for constants and enums</h3>

Use strings as the values for constants or sets of enumerated values.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use strings as the values for constants or sets of enumerated values.
Use strings as the values for constants or sets of enumerated values.
See [[#naming-is-hard]] when choosing strings.

Keep in mind that most web developers aren't native English speakers.
Whenever possible, names should be chosen that use common vocabulary
a majority of English speakers are likely to understand when first encountering the name.
Abbreviations should be avoided,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/w3ctag/process/blob/main/style-guide.md#use-the-active-voice

Suggested change
Abbreviations should be avoided,
Avoid abbreviations,

Comment on lines +3801 to +3803
Abbreviations should be avoided,
except in cases where an abbreviation is extremely common and easy to understand.
For example `UIEvent`, where "`UI`" stands for user interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of "Value readability over brevity" in the next non-example paragraph. How about

Value readability over brevity.
Often this means to avoid abbreviations.
Keep in mind, however, that

You could add the "UI" example into that example. It might be good to also have an example of when the abbreviation was a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enums should avoid abbreviations
3 participants