muttley73 / jlibs

Automatically exported from code.google.com/p/jlibs
0 stars 0 forks source link

Inconsistent Random interface #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The functions defined in 
\jlibs-read-only\core\src\main\java\jlibs\core\util\RandomUtil.java
have an inconsistent interface.

max is excluded in
double random(double min, double max)     [and float]
but included in
int random(int min, int max)              [and short, long, byte]

This complicates the usage of these standard functions.

Possible solutions:
1. either include or exclude max in all cases.
2. add javadoc documentation, such that the user can read what the function 
does without the need to look at the actual implementation file.
 The additional documentation could look like:
    /** Random integer value
      * @param min minimum integer value (inclusive)
      * @param max maximum integer value (inclusive)
      * @return a random integer in the range [min, max]
      */
    public static int random(int min, int max)

Original issue reported on code.google.com by Pierre.v...@gmail.com on 3 Dec 2013 at 1:35