Re: AW: [commons-lang3] NumberUtils feature

2018-01-01 Thread Lucas Carvalho
Hello Javen,

Thanks for you reply, when i sended the code, i have writend quickly,
however, if this feature i`ll be aproved, i will follow java / API
convension.

Ps. When I think in "between function", the first thing that comes in the
head is SQL BETWEEN ...

Obrigado.

Atenciosamente

Lucas Carvalho

*Fone *- 34 9 9903 4621

On Mon, Jan 1, 2018 at 7:27 AM, Javen O'Neal  wrote:

> I'm -1 for a static function as suggested by Lucas. It doesn't improve code
> readability, and I'd argue that it decreases readability because of needing
> to memorize operator order, ambiguous inclusivity of endpoints (unless you
> add isStrictlyBetween), and doesn't gracefully handle mixed data types,
> especially non-primitives like fixed precision decimals or fractions.
>
> Even with better named endpoints x and y as min/max, lowerBound/upperBound.
> What significant benefit does defining this function provide?
>
> Java syntax might not be as concise as other languages like Python that
> allow writing "lowerBound <= value <= upperBound", but a function call
> doesn't seem right here.
>
> BiInclusiveRange(lowerBound, upperBound).contains(value) seems like a
> better approach.
>
> On Dec 31, 2017 02:31, "Gilles"  wrote:
>
> On Sat, 30 Dec 2017 14:25:32 +0100, Jan Matèrne wrote:
>
> > Maybe open the comparators and use a fluent API?
> > is(42).between(10).and(50) == true
> > is(10).between(10).and(20) == false
> > is(10).between(10).and(20).includingLeft() == true
> > is(50).between(10).and(50) == false
> > is(50).between(10).and(50).includingRight() == true
> >
>
> There is "Range":
>   http://commons.apache.org/proper/commons-lang/javadocs/api-
> release/org/apache/commons/lang3/Range.html
>
> Is the original suggestion meant to create an implementation
> for primitive types?
>
> Gilles
>
>
>
> >
> > Just quick thoughts ...
> >
> > Jan
> >
> >
> > -Ursprüngliche Nachricht-
> >> Von: Gilles [mailto:gil...@harfang.homelinux.org]
> >> Gesendet: Freitag, 29. Dezember 2017 22:46
> >> An: dev@commons.apache.org
> >> Betreff: Re: [commons-lang3] NumberUtils feature
> >>
> >> On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
> >> > Gilles, thanks for you reply.
> >> >
> >> > I will consider your sugestions.
> >> >
> >> > So, can i open a issue in jira (apache commons) and implement this
> >> > feature?
> >>
> >> Better wait for other opinions on the various suggestions, as it
> >> impacts on which JIRA project you'd open the issue.
> >>
> >> Regards,
> >> Gilles
> >>
> >> >
> >> > Thanks.
> >> >
> >> > Lucas Carvalho
> >> >
> >> >
> >> >
> >> > On Fri, Dec 29, 2017 at 12:25 PM, Gilles
> >> > 
> >> > wrote:
> >> >
> >> >> Hi.
> >> >>
> >> >> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
> >> >>
> >> >>> I`m sorry,
> >> >>>
> >> >>> Now code in "text":
> >> >>>
> >> >>> public static boolean between(final int value, final int x, final
> >> >>> int y) {
> >> >>>
> >> >>>return value >= x && value <= y;
> >> >>>
> >> >>> }
> >> >>>
> >> >>>
> >> >>> public static boolean between(final short value, final short x,
> >> >>> final short
> >> >>> y) {
> >> >>>
> >> >>>return value >= x && value <= y;
> >> >>>
> >> >>> }
> >> >>>
> >> >>
> >> >> To comply with the Java convention, it should probably be
> >> >> "isBetween".
> >> >>
> >> >> Incidently, this also shows a weakness of "Utils" classes: the
> >> >> "target"
> >> >> (which would normally be "this") is on the same footing as the other
> >> >> arguments (the bounds of the interval here).
> >> >>
> >> >> Also the naming does not reflect whether bounds are included or not:
> >> >> usually, one would assume that the left bound is included (>=) but
> >> >> not the right one (<).
> >> >>
> >> >> Then, what about "between(15, 20, 10)"?
> >> >>
> >> >> Finally, we should consider whether to continue bloating
> >> >> "NumberUtils"
> >> >> in "Lang" or move some of it to the new "Numbers" component.[1]
> >> >>
> >> >> Regards,
> >> >> Gilles
> >> >>
> >> >> [1]
> >> >> https://git1-us-west.apache.org/repos/asf?p=commons-
> >> numbers.git;a=tre
> >> >> e
> >> >>
> >> >>
> >> >>>
> >> >>>
> >> >>> Obrigado.
> >> >>>
> >> >>> Atenciosamente
> >> >>>
> >> >>> Lucas Carvalho
> >> >>>
> >> >>> *Fone *- 34 9 9903 4621
> >> >>>
> >> >>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
> >> >>> 
> >> >>> wrote:
> >> >>>
> >> >>> Hi.
> >> 
> >>  On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:
> >> 
> >>  Hello everybody,
> >> >
> >> > I want know if the feature "between" in NumberUtils lib has be
> >> > discussed?
> >> > I
> >> > use this methods a lot and i would like to share this code in
> >> > apache commons.
> >> >
> >> > Below i share a example:
> >> >
> >> > [image: Inline image 1]
> >> >
> >> >
> >>  All I can see is the above.
> >>  [Perhaps the image was stripped.]
> >> 
> 

Re: AW: [commons-lang3] NumberUtils feature

2018-01-01 Thread Lucas Carvalho
Hi Gilles,

When was thinking about this implementation, i was thinking in primitive
types and Object (Integer, Double), but for Object, i think "Range" is
ok to use.

Thanks,

Lucas

On Sun, Dec 31, 2017 at 8:30 AM, Gilles 
wrote:

> On Sat, 30 Dec 2017 14:25:32 +0100, Jan Matèrne wrote:
>
>> Maybe open the comparators and use a fluent API?
>> is(42).between(10).and(50) == true
>> is(10).between(10).and(20) == false
>> is(10).between(10).and(20).includingLeft() == true
>> is(50).between(10).and(50) == false
>> is(50).between(10).and(50).includingRight() == true
>>
>
> There is "Range":
>   http://commons.apache.org/proper/commons-lang/javadocs/api-
> release/org/apache/commons/lang3/Range.html
>
> Is the original suggestion meant to create an implementation
> for primitive types?
>
> Gilles
>
>
>>
>> Just quick thoughts ...
>>
>> Jan
>>
>>
>> -Ursprüngliche Nachricht-
>>> Von: Gilles [mailto:gil...@harfang.homelinux.org]
>>> Gesendet: Freitag, 29. Dezember 2017 22:46
>>> An: dev@commons.apache.org
>>> Betreff: Re: [commons-lang3] NumberUtils feature
>>>
>>> On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
>>> > Gilles, thanks for you reply.
>>> >
>>> > I will consider your sugestions.
>>> >
>>> > So, can i open a issue in jira (apache commons) and implement this
>>> > feature?
>>>
>>> Better wait for other opinions on the various suggestions, as it
>>> impacts on which JIRA project you'd open the issue.
>>>
>>> Regards,
>>> Gilles
>>>
>>> >
>>> > Thanks.
>>> >
>>> > Lucas Carvalho
>>> >
>>> >
>>> >
>>> > On Fri, Dec 29, 2017 at 12:25 PM, Gilles
>>> > 
>>> > wrote:
>>> >
>>> >> Hi.
>>> >>
>>> >> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
>>> >>
>>> >>> I`m sorry,
>>> >>>
>>> >>> Now code in "text":
>>> >>>
>>> >>> public static boolean between(final int value, final int x, final
>>> >>> int y) {
>>> >>>
>>> >>>return value >= x && value <= y;
>>> >>>
>>> >>> }
>>> >>>
>>> >>>
>>> >>> public static boolean between(final short value, final short x,
>>> >>> final short
>>> >>> y) {
>>> >>>
>>> >>>return value >= x && value <= y;
>>> >>>
>>> >>> }
>>> >>>
>>> >>
>>> >> To comply with the Java convention, it should probably be
>>> >> "isBetween".
>>> >>
>>> >> Incidently, this also shows a weakness of "Utils" classes: the
>>> >> "target"
>>> >> (which would normally be "this") is on the same footing as the other
>>> >> arguments (the bounds of the interval here).
>>> >>
>>> >> Also the naming does not reflect whether bounds are included or not:
>>> >> usually, one would assume that the left bound is included (>=) but
>>> >> not the right one (<).
>>> >>
>>> >> Then, what about "between(15, 20, 10)"?
>>> >>
>>> >> Finally, we should consider whether to continue bloating
>>> >> "NumberUtils"
>>> >> in "Lang" or move some of it to the new "Numbers" component.[1]
>>> >>
>>> >> Regards,
>>> >> Gilles
>>> >>
>>> >> [1]
>>> >> https://git1-us-west.apache.org/repos/asf?p=commons-
>>> numbers.git;a=tre
>>> >> e
>>> >>
>>> >>
>>> >>>
>>> >>>
>>> >>> Obrigado.
>>> >>>
>>> >>> Atenciosamente
>>> >>>
>>> >>> Lucas Carvalho
>>> >>>
>>> >>> *Fone *- 34 9 9903 4621
>>> >>>
>>> >>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
>>> >>> 
>>> >>> wrote:
>>> >>>
>>> >>> Hi.
>>> 
>>>  On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:
>>> 
>>>  Hello everybody,
>>> >
>>> > I want know if the feature "between" in NumberUtils lib has be
>>> > discussed?
>>> > I
>>> > use this methods a lot and i would like to share this code in
>>> > apache commons.
>>> >
>>> > Below i share a example:
>>> >
>>> > [image: Inline image 1]
>>> >
>>> >
>>>  All I can see is the above.
>>>  [Perhaps the image was stripped.]
>>> 
>>>  I assume it is code; so, please write it here as "text".
>>> 
>>>  Thanks,
>>>  Gilles
>>> 
>>> 
>>>  Thanks.
>>> >
>>> > Lucas Carvalho
>>>
>>
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


Re: AW: [commons-lang3] NumberUtils feature

2018-01-01 Thread Javen O'Neal
I'm -1 for a static function as suggested by Lucas. It doesn't improve code
readability, and I'd argue that it decreases readability because of needing
to memorize operator order, ambiguous inclusivity of endpoints (unless you
add isStrictlyBetween), and doesn't gracefully handle mixed data types,
especially non-primitives like fixed precision decimals or fractions.

Even with better named endpoints x and y as min/max, lowerBound/upperBound.
What significant benefit does defining this function provide?

Java syntax might not be as concise as other languages like Python that
allow writing "lowerBound <= value <= upperBound", but a function call
doesn't seem right here.

BiInclusiveRange(lowerBound, upperBound).contains(value) seems like a
better approach.

On Dec 31, 2017 02:31, "Gilles"  wrote:

On Sat, 30 Dec 2017 14:25:32 +0100, Jan Matèrne wrote:

> Maybe open the comparators and use a fluent API?
> is(42).between(10).and(50) == true
> is(10).between(10).and(20) == false
> is(10).between(10).and(20).includingLeft() == true
> is(50).between(10).and(50) == false
> is(50).between(10).and(50).includingRight() == true
>

There is "Range":
  http://commons.apache.org/proper/commons-lang/javadocs/api-
release/org/apache/commons/lang3/Range.html

Is the original suggestion meant to create an implementation
for primitive types?

Gilles



>
> Just quick thoughts ...
>
> Jan
>
>
> -Ursprüngliche Nachricht-
>> Von: Gilles [mailto:gil...@harfang.homelinux.org]
>> Gesendet: Freitag, 29. Dezember 2017 22:46
>> An: dev@commons.apache.org
>> Betreff: Re: [commons-lang3] NumberUtils feature
>>
>> On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
>> > Gilles, thanks for you reply.
>> >
>> > I will consider your sugestions.
>> >
>> > So, can i open a issue in jira (apache commons) and implement this
>> > feature?
>>
>> Better wait for other opinions on the various suggestions, as it
>> impacts on which JIRA project you'd open the issue.
>>
>> Regards,
>> Gilles
>>
>> >
>> > Thanks.
>> >
>> > Lucas Carvalho
>> >
>> >
>> >
>> > On Fri, Dec 29, 2017 at 12:25 PM, Gilles
>> > 
>> > wrote:
>> >
>> >> Hi.
>> >>
>> >> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
>> >>
>> >>> I`m sorry,
>> >>>
>> >>> Now code in "text":
>> >>>
>> >>> public static boolean between(final int value, final int x, final
>> >>> int y) {
>> >>>
>> >>>return value >= x && value <= y;
>> >>>
>> >>> }
>> >>>
>> >>>
>> >>> public static boolean between(final short value, final short x,
>> >>> final short
>> >>> y) {
>> >>>
>> >>>return value >= x && value <= y;
>> >>>
>> >>> }
>> >>>
>> >>
>> >> To comply with the Java convention, it should probably be
>> >> "isBetween".
>> >>
>> >> Incidently, this also shows a weakness of "Utils" classes: the
>> >> "target"
>> >> (which would normally be "this") is on the same footing as the other
>> >> arguments (the bounds of the interval here).
>> >>
>> >> Also the naming does not reflect whether bounds are included or not:
>> >> usually, one would assume that the left bound is included (>=) but
>> >> not the right one (<).
>> >>
>> >> Then, what about "between(15, 20, 10)"?
>> >>
>> >> Finally, we should consider whether to continue bloating
>> >> "NumberUtils"
>> >> in "Lang" or move some of it to the new "Numbers" component.[1]
>> >>
>> >> Regards,
>> >> Gilles
>> >>
>> >> [1]
>> >> https://git1-us-west.apache.org/repos/asf?p=commons-
>> numbers.git;a=tre
>> >> e
>> >>
>> >>
>> >>>
>> >>>
>> >>> Obrigado.
>> >>>
>> >>> Atenciosamente
>> >>>
>> >>> Lucas Carvalho
>> >>>
>> >>> *Fone *- 34 9 9903 4621
>> >>>
>> >>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
>> >>> 
>> >>> wrote:
>> >>>
>> >>> Hi.
>> 
>>  On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:
>> 
>>  Hello everybody,
>> >
>> > I want know if the feature "between" in NumberUtils lib has be
>> > discussed?
>> > I
>> > use this methods a lot and i would like to share this code in
>> > apache commons.
>> >
>> > Below i share a example:
>> >
>> > [image: Inline image 1]
>> >
>> >
>>  All I can see is the above.
>>  [Perhaps the image was stripped.]
>> 
>>  I assume it is code; so, please write it here as "text".
>> 
>>  Thanks,
>>  Gilles
>> 
>> 
>>  Thanks.
>> >
>> > Lucas Carvalho
>>
>

-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org


Re: AW: [commons-lang3] NumberUtils feature

2017-12-31 Thread Gilles

On Sat, 30 Dec 2017 14:25:32 +0100, Jan Matèrne wrote:

Maybe open the comparators and use a fluent API?
is(42).between(10).and(50) == true
is(10).between(10).and(20) == false
is(10).between(10).and(20).includingLeft() == true
is(50).between(10).and(50) == false
is(50).between(10).and(50).includingRight() == true


There is "Range":
  
http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/Range.html


Is the original suggestion meant to create an implementation
for primitive types?

Gilles




Just quick thoughts ...

Jan



-Ursprüngliche Nachricht-
Von: Gilles [mailto:gil...@harfang.homelinux.org]
Gesendet: Freitag, 29. Dezember 2017 22:46
An: dev@commons.apache.org
Betreff: Re: [commons-lang3] NumberUtils feature

On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
> Gilles, thanks for you reply.
>
> I will consider your sugestions.
>
> So, can i open a issue in jira (apache commons) and implement this
> feature?

Better wait for other opinions on the various suggestions, as it
impacts on which JIRA project you'd open the issue.

Regards,
Gilles

>
> Thanks.
>
> Lucas Carvalho
>
>
>
> On Fri, Dec 29, 2017 at 12:25 PM, Gilles
> 
> wrote:
>
>> Hi.
>>
>> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
>>
>>> I`m sorry,
>>>
>>> Now code in "text":
>>>
>>> public static boolean between(final int value, final int x, 
final

>>> int y) {
>>>
>>>return value >= x && value <= y;
>>>
>>> }
>>>
>>>
>>> public static boolean between(final short value, final short x,
>>> final short
>>> y) {
>>>
>>>return value >= x && value <= y;
>>>
>>> }
>>>
>>
>> To comply with the Java convention, it should probably be
>> "isBetween".
>>
>> Incidently, this also shows a weakness of "Utils" classes: the
>> "target"
>> (which would normally be "this") is on the same footing as the 
other

>> arguments (the bounds of the interval here).
>>
>> Also the naming does not reflect whether bounds are included or 
not:
>> usually, one would assume that the left bound is included (>=) 
but

>> not the right one (<).
>>
>> Then, what about "between(15, 20, 10)"?
>>
>> Finally, we should consider whether to continue bloating
>> "NumberUtils"
>> in "Lang" or move some of it to the new "Numbers" component.[1]
>>
>> Regards,
>> Gilles
>>
>> [1]
>> https://git1-us-west.apache.org/repos/asf?p=commons-
numbers.git;a=tre
>> e
>>
>>
>>>
>>>
>>> Obrigado.
>>>
>>> Atenciosamente
>>>
>>> Lucas Carvalho
>>>
>>> *Fone *- 34 9 9903 4621
>>>
>>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
>>> 
>>> wrote:
>>>
>>> Hi.

 On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:

 Hello everybody,
>
> I want know if the feature "between" in NumberUtils lib has be
> discussed?
> I
> use this methods a lot and i would like to share this code in
> apache commons.
>
> Below i share a example:
>
> [image: Inline image 1]
>
>
 All I can see is the above.
 [Perhaps the image was stripped.]

 I assume it is code; so, please write it here as "text".

 Thanks,
 Gilles


 Thanks.
>
> Lucas Carvalho



-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org



AW: [commons-lang3] NumberUtils feature

2017-12-30 Thread jhm
Maybe open the comparators and use a fluent API?
is(42).between(10).and(50) == true
is(10).between(10).and(20) == false
is(10).between(10).and(20).includingLeft() == true
is(50).between(10).and(50) == false
is(50).between(10).and(50).includingRight() == true


Just quick thoughts ...

Jan


> -Ursprüngliche Nachricht-
> Von: Gilles [mailto:gil...@harfang.homelinux.org]
> Gesendet: Freitag, 29. Dezember 2017 22:46
> An: dev@commons.apache.org
> Betreff: Re: [commons-lang3] NumberUtils feature
> 
> On Fri, 29 Dec 2017 16:19:05 -0200, Lucas Carvalho wrote:
> > Gilles, thanks for you reply.
> >
> > I will consider your sugestions.
> >
> > So, can i open a issue in jira (apache commons) and implement this
> > feature?
> 
> Better wait for other opinions on the various suggestions, as it
> impacts on which JIRA project you'd open the issue.
> 
> Regards,
> Gilles
> 
> >
> > Thanks.
> >
> > Lucas Carvalho
> >
> >
> >
> > On Fri, Dec 29, 2017 at 12:25 PM, Gilles
> > 
> > wrote:
> >
> >> Hi.
> >>
> >> On Fri, 29 Dec 2017 11:53:29 -0200, Lucas Carvalho wrote:
> >>
> >>> I`m sorry,
> >>>
> >>> Now code in "text":
> >>>
> >>> public static boolean between(final int value, final int x, final
> >>> int y) {
> >>>
> >>>return value >= x && value <= y;
> >>>
> >>> }
> >>>
> >>>
> >>> public static boolean between(final short value, final short x,
> >>> final short
> >>> y) {
> >>>
> >>>return value >= x && value <= y;
> >>>
> >>> }
> >>>
> >>
> >> To comply with the Java convention, it should probably be
> >> "isBetween".
> >>
> >> Incidently, this also shows a weakness of "Utils" classes: the
> >> "target"
> >> (which would normally be "this") is on the same footing as the other
> >> arguments (the bounds of the interval here).
> >>
> >> Also the naming does not reflect whether bounds are included or not:
> >> usually, one would assume that the left bound is included (>=) but
> >> not the right one (<).
> >>
> >> Then, what about "between(15, 20, 10)"?
> >>
> >> Finally, we should consider whether to continue bloating
> >> "NumberUtils"
> >> in "Lang" or move some of it to the new "Numbers" component.[1]
> >>
> >> Regards,
> >> Gilles
> >>
> >> [1]
> >> https://git1-us-west.apache.org/repos/asf?p=commons-
> numbers.git;a=tre
> >> e
> >>
> >>
> >>>
> >>>
> >>> Obrigado.
> >>>
> >>> Atenciosamente
> >>>
> >>> Lucas Carvalho
> >>>
> >>> *Fone *- 34 9 9903 4621
> >>>
> >>> On Fri, Dec 29, 2017 at 11:47 AM, Gilles
> >>> 
> >>> wrote:
> >>>
> >>> Hi.
> 
>  On Fri, 29 Dec 2017 09:51:59 -0200, Lucas Carvalho wrote:
> 
>  Hello everybody,
> >
> > I want know if the feature "between" in NumberUtils lib has be
> > discussed?
> > I
> > use this methods a lot and i would like to share this code in
> > apache commons.
> >
> > Below i share a example:
> >
> > [image: Inline image 1]
> >
> >
>  All I can see is the above.
>  [Perhaps the image was stripped.]
> 
>  I assume it is code; so, please write it here as "text".
> 
>  Thanks,
>  Gilles
> 
> 
>  Thanks.
> >
> > Lucas Carvalho
> 
> 
> -
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org