You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2016/09/17 14:51:51 UTC

[LANG] Methods introduced in LANG-1134

Hi,

LANG-1134 introduced new methods to Validate. I'm not fond of the API as is
currently is. Here are my concerns:

- When comparing numeral values usually we talk about greaterThan and
lessThan. The new API in Validate uses "smaller" and "greater"
- we have a method called "different" which checks that two reference are
not equal to each other. Who about calling that notEquals?

Regards,
Benedikt

Re: [LANG] Methods introduced in LANG-1134

Posted by Benedikt Ritter <br...@apache.org>.
Hi,

I've reviewed the current code again and I've come to the conclusion that
we should revert it completely. Here is an example of why I think it need
polishing:

public static void smaller(final long value, final long max, final String
message, final Object... values) {
   if (value >= max) {
      throw new IllegalArgumentException(String.format(message, values));
   }
}

while the double variant is implemented like this:

public static void smaller(final double value, final double max, final
String message, final Object... values) {
   if (!(value < max)) {
       throw new IllegalArgumentException(String.format(message, values));
   }
}

Why are two methods which do exactly the same implemented completely
different? I'm all smaller/greater methods. The (not)Non and (not)Finite
methods look good to me, so we can keep them.

Regards,
Benedikt

Pascal Schumacher <pa...@gmx.net> schrieb am So., 18. Sep. 2016
um 20:26 Uhr:

> Am 18.09.2016 um 13:58 schrieb Benedikt Ritter:
> > The problem with the current API is that we can't get rid of the "Object"
> > suffix:
> >
> > public static void different(long, long, String, Object...)
> > public static <T> void differentObject(T, T, String, Object...)
> >
> > when I change the second method name to "different" (or rename both to
> > notEquals), the method calls become ambiguous. This has something to do
> > with the varargs argument at the end.
> I would remove the (unreleased) primitive variants and reduce it to the
> object variant.
> > I'm currently not sure how to handle this. I'd rather like to release 3.5
> > without this API.
> +1 I think it's better to have a new release soon than having this hold
> up the release.
>
> -Pascal
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: [LANG] Methods introduced in LANG-1134

Posted by Pascal Schumacher <pa...@gmx.net>.
Am 18.09.2016 um 13:58 schrieb Benedikt Ritter:
> The problem with the current API is that we can't get rid of the "Object"
> suffix:
>
> public static void different(long, long, String, Object...)
> public static <T> void differentObject(T, T, String, Object...)
>
> when I change the second method name to "different" (or rename both to
> notEquals), the method calls become ambiguous. This has something to do
> with the varargs argument at the end.
I would remove the (unreleased) primitive variants and reduce it to the 
object variant.
> I'm currently not sure how to handle this. I'd rather like to release 3.5
> without this API.
+1 I think it's better to have a new release soon than having this hold 
up the release.

-Pascal


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


Re: [LANG] Methods introduced in LANG-1134

Posted by Benedikt Ritter <br...@apache.org>.
The problem with the current API is that we can't get rid of the "Object"
suffix:

public static void different(long, long, String, Object...)
public static <T> void differentObject(T, T, String, Object...)

when I change the second method name to "different" (or rename both to
notEquals), the method calls become ambiguous. This has something to do
with the varargs argument at the end.

I'm currently not sure how to handle this. I'd rather like to release 3.5
without this API.

Thoughts?
Benedikt

Benedikt Ritter <br...@apache.org> schrieb am So., 18. Sep. 2016 um
13:15 Uhr:

> Hello,
>
> sebb <se...@gmail.com> schrieb am So., 18. Sep. 2016 um 12:21 Uhr:
>
>> I agree; use notEquals, greaterThan, lessThan
>>
>> 'different' is ambiguous - does it mean notSame or notEquals?
>>
>
> the latter.
>
>
>>
>> On 17 September 2016 at 16:57, Gary Gregory <ga...@gmail.com>
>> wrote:
>> > JUnit makes the distinction between "same" for the same object and
>> "equals"
>> > and calling equals(), maybe this would help here.
>> >
>> > http://junit.org/junit4/javadoc/4.12/org/junit/Assert.html
>> >
>> > Gary
>> >
>> > On Sep 17, 2016 7:52 AM, "Benedikt Ritter" <br...@apache.org> wrote:
>> >
>> >> Hi,
>> >>
>> >> LANG-1134 introduced new methods to Validate. I'm not fond of the API
>> as is
>> >> currently is. Here are my concerns:
>> >>
>> >> - When comparing numeral values usually we talk about greaterThan and
>> >> lessThan. The new API in Validate uses "smaller" and "greater"
>> >> - we have a method called "different" which checks that two reference
>> are
>> >> not equal to each other. Who about calling that notEquals?
>> >>
>> >> Regards,
>> >> Benedikt
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>

Re: [LANG] Methods introduced in LANG-1134

Posted by Benedikt Ritter <br...@apache.org>.
Hello,

sebb <se...@gmail.com> schrieb am So., 18. Sep. 2016 um 12:21 Uhr:

> I agree; use notEquals, greaterThan, lessThan
>
> 'different' is ambiguous - does it mean notSame or notEquals?
>

the latter.


>
> On 17 September 2016 at 16:57, Gary Gregory <ga...@gmail.com>
> wrote:
> > JUnit makes the distinction between "same" for the same object and
> "equals"
> > and calling equals(), maybe this would help here.
> >
> > http://junit.org/junit4/javadoc/4.12/org/junit/Assert.html
> >
> > Gary
> >
> > On Sep 17, 2016 7:52 AM, "Benedikt Ritter" <br...@apache.org> wrote:
> >
> >> Hi,
> >>
> >> LANG-1134 introduced new methods to Validate. I'm not fond of the API
> as is
> >> currently is. Here are my concerns:
> >>
> >> - When comparing numeral values usually we talk about greaterThan and
> >> lessThan. The new API in Validate uses "smaller" and "greater"
> >> - we have a method called "different" which checks that two reference
> are
> >> not equal to each other. Who about calling that notEquals?
> >>
> >> Regards,
> >> Benedikt
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: [LANG] Methods introduced in LANG-1134

Posted by sebb <se...@gmail.com>.
I agree; use notEquals, greaterThan, lessThan

'different' is ambiguous - does it mean notSame or notEquals?

On 17 September 2016 at 16:57, Gary Gregory <ga...@gmail.com> wrote:
> JUnit makes the distinction between "same" for the same object and "equals"
> and calling equals(), maybe this would help here.
>
> http://junit.org/junit4/javadoc/4.12/org/junit/Assert.html
>
> Gary
>
> On Sep 17, 2016 7:52 AM, "Benedikt Ritter" <br...@apache.org> wrote:
>
>> Hi,
>>
>> LANG-1134 introduced new methods to Validate. I'm not fond of the API as is
>> currently is. Here are my concerns:
>>
>> - When comparing numeral values usually we talk about greaterThan and
>> lessThan. The new API in Validate uses "smaller" and "greater"
>> - we have a method called "different" which checks that two reference are
>> not equal to each other. Who about calling that notEquals?
>>
>> Regards,
>> Benedikt
>>

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


Re: [LANG] Methods introduced in LANG-1134

Posted by Gary Gregory <ga...@gmail.com>.
JUnit makes the distinction between "same" for the same object and "equals"
and calling equals(), maybe this would help here.

http://junit.org/junit4/javadoc/4.12/org/junit/Assert.html

Gary

On Sep 17, 2016 7:52 AM, "Benedikt Ritter" <br...@apache.org> wrote:

> Hi,
>
> LANG-1134 introduced new methods to Validate. I'm not fond of the API as is
> currently is. Here are my concerns:
>
> - When comparing numeral values usually we talk about greaterThan and
> lessThan. The new API in Validate uses "smaller" and "greater"
> - we have a method called "different" which checks that two reference are
> not equal to each other. Who about calling that notEquals?
>
> Regards,
> Benedikt
>