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

Make percentage input consistent #43

Closed
wants to merge 2 commits into from

Conversation

s3cur3
Copy link
Contributor

@s3cur3 s3cur3 commented Jan 6, 2025

This makes the Percentage feature more consistent, such that the input is accepted as a value between 0 and 100. Previously the input was required to be a ratio (between 0 and 1), but it was then displayed as a percentage (effectively "#{ratio / 100}%"). With this change, the formatting of the input and later display match.

Before After
before after

Resolves tompave/fun_with_flags#188

This makes the Percentage feature more consistent, such that the input is accepted as a value between 0 and 100. Previously the input was required to be a ratio (between 0 and 1), but it was then displayed as a percentage (effectively `"#{ratio / 100}%"`). With this change, the formatting of the input and later display match.
@s3cur3 s3cur3 mentioned this pull request Jan 11, 2025
@tompave
Copy link
Owner

tompave commented Feb 23, 2025

Thank you for submitting the PR, and for describing the issue in tompave/fun_with_flags#188. As I said there, I closed that issue in order to avoid duplication. We can discuss this here in the PR.

@tompave
Copy link
Owner

tompave commented Feb 24, 2025

I see where you're coming from but, to be honest, I think I prefer dealing with floats between 0 and 1, rather than having to manage percentages expressed the "humanized" way in the range 0...100.

Asking users to enter a 0..1 float was a deliberate choice because I find it simpler on two regards:

  1. It's easier to reason about. I admit this is subjective, and I mainly have anecdotal evidence to support this, based on the observation that software developers are mostly used to think of percentages as floats in 0..1.
  2. It's easier to maintain, because the flag and gate model represent these percentages as a 0..1 float. We might argue that it's a leaky abstraction, but at least it's one that removes complexity from the system. For example, in your code changes you are forced to divide the input by 100.

I admit that displaying "30%" in the UI might be confusing, but that's what the next bit of UI is for, the one that says: "raw value: 0.1234". The layout is ugly though, I admit that. 😆

So I think I'm going to reject this PR as it is now, sorry.

However, I welcome a PR that tidies up the UI to make it easier to understand, provided that the input accepts the same 0..1 values that does right now.

@s3cur3
Copy link
Contributor Author

s3cur3 commented Feb 24, 2025

If you're set on keeping it as a ratio, can we change the text and input labels to say "ratio" or "fraction" instead of "percentage"? I think it's perfectly understandable as a ratio... the confusion comes from labeling what is actually a ratio as a percentage. Entering 0.42 in the input field is not a percentage of time or percentage of actors at all.

percent

@tompave
Copy link
Owner

tompave commented Feb 24, 2025

In hindsight, I'd agree that cramming all that info into the placeholder attribute of the form input was a poor choice: "e.g. 0.421337 for 42.1337%". That short example should be phrased better, and should be more readable.

But I stand by the idea that "percentage" is the right word there. I wouldn't change it to say "ratio" in the UI because the package API uses "percentage", and I wouldn't change the input to accept a 0..100 float because the Elixir API accepts 0..1 floats.

Another point to keep in mind is that the current wording hasn't been a problem so far; at least I've not heard anyone complain. That doesn't necessarily mean that things cannot be improved (they always can), but at the very least it means that I must consider consistency and predictability in both the API and the web UI.

Therefore, I'm still inclined to reject the PR, sorry.

@s3cur3
Copy link
Contributor Author

s3cur3 commented Feb 24, 2025

Fair enough! We'll continue using our fork. 👍

@tompave
Copy link
Owner

tompave commented Feb 24, 2025

Very well, at least I'm glad you're unblocked! 👍 Thanks for using the (main? 😆) package!

@tompave tompave closed this Feb 24, 2025
@s3cur3
Copy link
Contributor Author

s3cur3 commented Feb 24, 2025

Thank you for all your work on FWF!

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.

Make percentage input consistent
2 participants