You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by Justin Mclean <ju...@classsoftware.com> on 2018/02/17 07:14:24 UTC
Does this seem odd to you?
Hi,
It's a very minor thing I know but I just came access this:
public static TpduSize valueForGivenSize(int pduSize) {
if(pduSize < 0) {
throw new IllegalArgumentException("PduSize has to be greater than 0");
}
assert pduSize > 0;
And have a few questions:
- Should we be using asserts in code like that?
- Wouldn't it be easier to just change the first condition to match the message i.e. <= rather than < and drop the assert?
Just asking cos there may be a something I missing here. It’s in java/isotp/netty/model/types/TpduSize.java BTW.
Thanks,
Justin
Re: Does this seem odd to you?
Posted by Christofer Dutz <ch...@c-ware.de>.
Ok ... fixed that __
Thanks again for finding (
Chris
Am 17.02.18, 09:43 schrieb "Christofer Dutz" <ch...@c-ware.de>:
If it's code I have written, it was a mistake ... I would agree to use the exception and not the assertion, because they can be turned off.
Chris
Outlook for Android<https://aka.ms/ghei36> herunterladen
________________________________
From: Justin Mclean <ju...@classsoftware.com>
Sent: Saturday, February 17, 2018 8:14:24 AM
To: dev@plc4x.apache.org
Subject: Does this seem odd to you?
Hi,
It's a very minor thing I know but I just came access this:
public static TpduSize valueForGivenSize(int pduSize) {
if(pduSize < 0) {
throw new IllegalArgumentException("PduSize has to be greater than 0");
}
assert pduSize > 0;
And have a few questions:
- Should we be using asserts in code like that?
- Wouldn't it be easier to just change the first condition to match the message i.e. <= rather than < and drop the assert?
Just asking cos there may be a something I missing here. It’s in java/isotp/netty/model/types/TpduSize.java BTW.
Thanks,
Justin
Re: Does this seem odd to you?
Posted by Christofer Dutz <ch...@c-ware.de>.
If it's code I have written, it was a mistake ... I would agree to use the exception and not the assertion, because they can be turned off.
Chris
Outlook for Android<https://aka.ms/ghei36> herunterladen
________________________________
From: Justin Mclean <ju...@classsoftware.com>
Sent: Saturday, February 17, 2018 8:14:24 AM
To: dev@plc4x.apache.org
Subject: Does this seem odd to you?
Hi,
It's a very minor thing I know but I just came access this:
public static TpduSize valueForGivenSize(int pduSize) {
if(pduSize < 0) {
throw new IllegalArgumentException("PduSize has to be greater than 0");
}
assert pduSize > 0;
And have a few questions:
- Should we be using asserts in code like that?
- Wouldn't it be easier to just change the first condition to match the message i.e. <= rather than < and drop the assert?
Just asking cos there may be a something I missing here. It’s in java/isotp/netty/model/types/TpduSize.java BTW.
Thanks,
Justin