Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36843
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: null checks |
| Date | 2017-07-09 13:10 +0200 |
| Message-ID | <eseh9cFk6shU1@mid.individual.net> (permalink) |
| References | <fb0314ea-bd97-4348-8af1-3ac9f9f46bdc@googlegroups.com> <ojoaip$pab$1@gioia.aioe.org> <70f5af57-8dc0-416c-b2aa-0bbbb47fc7b5@googlegroups.com> <ojobsn$rh8$1@gioia.aioe.org> |
On 07.07.2017 18:12, Arne Vajhøj wrote: > You need to choose between approaches: > 1) Annotate and let IDE/checktool give you warnings during dveelopment > 2) Make a runtime check > A) Insert the check code manually > B) Annotate and weave the check code in via AOP > I think approach 2A is the simple safe approach. Often the manual insertion is not necessary because the first method invoked will trigger a NPE. I tend to add explicit null checks * For methods when an argument is assigned a member variable which by class invariant must not be null and which does not invoke methods on the argument. This is often the case for constructors. * If the automatic null check on method invocation comes too late (e.g. when the work of the method is half through at the time and would require rolling back work). I also like to do argument checks like these before a synchronized block is entered. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 08:03 -0700
Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-07 11:49 -0400
Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 08:54 -0700
Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-07 12:12 -0400
Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 10:16 -0700
Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-08 22:33 +0200
Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-08 21:14 +0000
Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-08 17:51 -0400
Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-08 22:26 +0000
Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-08 18:28 -0400
Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-25 07:26 +0200
Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-25 12:12 +0000
Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-08 18:20 -0400
Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-10 05:35 -0700
Re: null checks Robert Klemme <shortcutter@googlemail.com> - 2017-07-09 13:10 +0200
Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-07 12:53 -0400
Re: null checks lewbloch@gmail.com - 2017-07-26 11:16 -0700
Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-26 11:40 -0700
Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-26 16:40 -0400
Re: null checks lewbloch@gmail.com - 2017-07-28 18:47 -0700
Re: null checks Wayne <wayne@nospam.invalid> - 2017-07-07 16:24 -0400
Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-08 22:32 +0200
Re: null checks Lothar Kimmeringer <news201705@kimmeringer.de> - 2017-07-09 15:59 +0200
Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-11 20:30 -0400
csiph-web