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/01/13 23:07:38 UTC

null Tpdu codes

Hi,

In writing a couple of bad code code I found that the the existing code would NPE when doing switch of a TdpuCode of null. In order to get around this I add a new enum of UNKNOWN and now have valueOF return that instead of null if the tpdu code is not in the enum map. Anyone think this is not the right approach?

Thanks,
Justin

Re: null Tpdu codes

Posted by Niclas Hedhman <ni...@hedhman.org>.
In general, I suggest to remove all use of null return values. It is the
bane of programming....

On Sun, Jan 14, 2018 at 3:18 PM, Christofer Dutz <ch...@c-ware.de>
wrote:

> Sounds good to me ... Eventually we should check, if this makes sense for
> the other enums.
>
> Chris
>
> Outlook for Android<https://aka.ms/ghei36> herunterladen
>
> ________________________________
> From: Justin Mclean <ju...@classsoftware.com>
> Sent: Sunday, January 14, 2018 12:07:38 AM
> To: dev@plc4x.apache.org
> Subject: null Tpdu codes
>
> Hi,
>
> In writing a couple of bad code code I found that the the existing code
> would NPE when doing switch of a TdpuCode of null. In order to get around
> this I add a new enum of UNKNOWN and now have valueOF return that instead
> of null if the tpdu code is not in the enum map. Anyone think this is not
> the right approach?
>
> Thanks,
> Justin
>



-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java

Re: null Tpdu codes

Posted by Christofer Dutz <ch...@c-ware.de>.
Sounds good to me ... Eventually we should check, if this makes sense for the other enums.

Chris

Outlook for Android<https://aka.ms/ghei36> herunterladen

________________________________
From: Justin Mclean <ju...@classsoftware.com>
Sent: Sunday, January 14, 2018 12:07:38 AM
To: dev@plc4x.apache.org
Subject: null Tpdu codes

Hi,

In writing a couple of bad code code I found that the the existing code would NPE when doing switch of a TdpuCode of null. In order to get around this I add a new enum of UNKNOWN and now have valueOF return that instead of null if the tpdu code is not in the enum map. Anyone think this is not the right approach?

Thanks,
Justin