On Sat, 14 Oct 2023 at 18:48, David Grudl <da...@grudl.com> wrote:

>
> A) The problem with nextFloat() is that the name creates a false
> expectation. Take a look at the following code:
> ```
> $randomizer = new \Random\Randomizer();
> $a = $randomizer->getFloat(100, 200); // number between 100..200
> $b = $randomizer->nextFloat(); // another number between 100..200 ???
> ```
>

I don't even get the point of  nextFloat. Its a random function, there is
no thing as "next".
I think the major pet peeve i have is that the "Randomizer" class is
encapsulating all random functions.
I would like to see each randomizer have its own class, since they are
under the Random namespace
anyway, I believe they should be Random/StringRandomizer,
Random/IntRandomizer,
Random/FloatRandomizer, so on so forth. Basically Ramdom/{Type}Randomizer.
This would
also allow more granular and specific functionality for each type.

For example, for this discussion, the class, Random/FloatRandomizer (and
IntRandomizer)
could be instatiated with its boundries.

```php
$randomFloat = new Random/FloatRandomizer($lowerBound, $upperBound,
$boundryInterval)
$a = $randomFloat->get();
$b = $randomFLoat->next();
```

Is that not more intuitive?

Reply via email to