-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Rename some methods related to redraw frequency #33732
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
Conversation
We considered these min/max names while working on this and decided they were more confusing than what we have now. -0 on my side. |
I have a mix feeling about this. I don't find the current name very clear, but I'm not sure the proposed one are way better. |
what about the actual property names? that seems more clear compared to |
Actually, talking about "frames per second" or "refresh rate" is much more common than "frame duration" or "refresh interval". So, why don't we rename these methods as one of the following alternatives? $progressBar->setRedrawFrequency(100);
$progressBar->minRefreshesPerSecond(5);
$progressBar->maxRefreshesPerSecond(10);
$progressBar->setRedrawFrequency(100);
$progressBar->minUpdatesPerSecond(5);
$progressBar->maxUpdatesPerSecond(10);
$progressBar->setRedrawFrequency(100);
$progressBar->minRedrawsPerSecond(5);
$progressBar->maxRedrawsPerSecond(10); |
My opinion: maxRefreshInterval/minRefreshInterval are better :) |
I'm in for If no consensus can be found, And I give a lower score to |
I can decipher them, but |
First I'd like to note that To denote a number of iterations between actions I'd choose Now that the word frequency is freed, we can use it to answer the question asked initially: $progressBar->setRedrawRegularity(100);
$progressBar->minRedrawFrequency(5);
$progressBar->maxRedrawFrequency(10); If we choose to stick to time units rather than frequency, I support min/maxRedrawInterval but not inverting the meaning. // interval cannot be less than 0.1s => max freq of 10 Hz
$progressBar->minRedrawInterval(0.1);
// interval cannot be more than 0.2s => min freq of 5 Hz
$progressBar->maxRedrawInterval(0.2); |
Starting the methods with just
|
Another proposition: public function setRedrawInterval(float $minPerSec, float $maxPerSec = 0.1); |
I think @andrewmy's comment is important:
Frequency in the current usage is misleading. As the top description says, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the discussion, I changed my mind and I'm 👍
The new wording is perfectly accurate on the technical level. Making it "boring" is a quality here.
I would not like having to define a frequency. 0.2
(redraw per seconds) is way harder to reason about than 5
(seconds between redraws).
Don't get mad at me 🙈 but ... now I'm the one who doesn't like my original proposal. The only proposal that I find self-explanatory is this one: $progressBar->minRedrawsPerSecond(5);
$progressBar->maxRedrawsPerSecond(10); Also, we already have a |
The existing method that contains the word "frequency" accepts... an interval as argument. I'm formally 👎 to use that term if that can help move forward :) |
@javiereguiluz please update the PR then... :) |
@ostrolucky could you please help me with the tests? I'm having lots of problems trying to understand how things work. This code for example is easy to understand: $bar = new ProgressBar($output = $this->getOutputStream(), 100);
$bar->setRedrawFrequency(1);
$bar->minRedrawsPerSecond(5);
$bar->maxRedrawsPerSecond(10);
// ...
sleep(1); The code sleeps for 1 second ... so we should have at least 5 redraws. Sadly, this is not how things work at all at the moment. Thanks for your help! |
Naming things is hard 😓 So, after talking with Nicolas, I've renamed this again following his suggestion (I think that the new name is equally self-explanatory, but even easier to understand and avoids problems like the division by zero): minSecondsBetweenRedraws(float $seconds)
maxSecondsBetweenRedraws(float $seconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(with a minor comment)
Thank you @javiereguiluz. |
This PR was merged into the 4.4 branch. Discussion ---------- [Console] Update some method names These were renamed in symfony/symfony#33732 Commits ------- 316a48b [Console] Update some method names
In #26339 we added
preventRedrawFasterThan()
andforceRedrawSlowerThan()
. While merging the docs for them (symfony/symfony-docs#12364) I thought that the method names are a bit hard to understand.In this PR I propose a renaming for your consideration. Thanks!
In the following example, we want to update the progress bar every 100 iterations, but not faster than 100ms or slower than 200ms.
Before
After