This is not the document you are looking for? Use the search form below to find more!

Report home > Others

Better Strategies for Null Handling in Java

0.00 (0 votes)
Document Description
Better Strategies for Null Handling in Java
File Details
Submitter
  • Name: ermenegilda
Embed Code:

Add New Comment




Related Documents

Strategies for Clinical Management of MRSA in the Community: Summary of an Experts' Meeting Convened by the Centers for Disease Control and Prevention

by: samanta, 24 pages

Methicillin-resistant Staphylococcus aureus (MRSA) has emerged as a cause of skin infections and, less commonly, invasive infections among otherwise healthy adults and children in the community ...

Checks and Balances: New Rules, New Strategies for Bank Customers in the 21st Century

by: shinta, 8 pages

How often do you visit or have some contact with your bank? Chances are you’d say it’s only once in a while and certainly not every day. But if you think about it, ...

summer training in JAVA

by: duccsystems, 11 pages

DUCC Systems invites all to the summer training in JAVA program. Batches start in June and July.

ieee 2010 projects in java / matlab SBGC ( chennai, trichy, india )

by: sathish, 55 pages

ieee 2010 projects in java chennai, ieee 2010 projects in java bangalore, ieee 2010 projects in java hyderabad, ieee 2010 projects matlab chennai, ieee 2010 projects matlab bangalore, ieee 2010 ...

Testing In Java

by: john, 42 pages

Testing in Java San Gabriel Valley Java Users Group http://www.sgvjug.org/ June 25, 2007 David ...

Luxurious home for Sale Rent in Noida | Luxurious Apartment on Rent Buy in Noida | Suraj Properties Call 9999278888 | Greater Noida Home for Sale

by: rishimsh, 4 pages

SURAJ PROPERTIES SURAJ PROPERTIES is North India's leading Realtors, established since 1989 is first and final stop for your all kind of Property related matters. We are professionally managed ...

Free training in java

by: ducc-systems, 8 pages

Summer Training Program We are an ,ISO 9001:2008 certified, IT Services, Software Development and Training Company based at New Delhi. DUCC ...

Programming in Java

by: dutcher, 375 pages

Java includes a huge number of built-in classes and interfaces. The programmer can use already existing class as is, create subclasses to modify existing classes, or implement interfaces to augment ...

Advanced concurrency control in Java

by: bonnie, 25 pages

Developing concurrent applications is not a trivial task. As programs grow larger and become more complex, advanced concurrency control mechanisms are needed to ensure that application consistency is ...

A Contrastive Study on Disagreement Strategies for Politeness between

by: hendrik, 12 pages

The purpose of this paper is to make a contrastive study of disagreement strategies for politeness between American English and Mandarin Chinese at the private interpersonal level for better EFL/ESL ...

Content Preview
Better Strategies for Null Handling in JavaStephan SchmidtTeam manager PMI-3Berlin, 05.08.2008Most problematic errors in Java2 runtime problems in JavaClassCastException„Solved“ with GenericsNullPointerException (NPE)Solution?2Problems with NPEs– RunTime Exception– Point of NPE easy to find=> But not clear where the NULL value comesfrom3Handling of NULL ValuesCheck beforeCheck afterif (map.containsKey("Hello")) {String name = map.get("Hello");String name = map.get(“hallo”);if (name != null) {} else { … }...} else { … }–Easy to forget–No support from type system–No tracking of NULL values•Can a reference be NULL ?4Null Handling in Groovydef user = users[“hello”]def streetname = user?.address?.streetSafe Navigation Operator ?.user, address can be NULLwill simply return NULL instead of throwing an exception5Null types in Nice languageNice language NULL types- ?String name => possibly NULL- String name => not NULLString name = null;=> Compiler error6NULL Handling with Annotations@NotNull, @Nullable in JavaIDEA and others, JSR 308Automatic checks for NULLIDEA tells you when NPEs will occure@NotNullpublic String get(@NotNull String name) { … } Everything not null and @Optional for NULL better solution7Scala Option ClassOption can have a value or not (think container with 0 or 1 elements). Subclasses are Some and NoneMust deal with None (NULL) value, cannot ignoreCalled Maybe (Just, Nothing) in Haskellmap.get("Hello") match {case Some(name) => // do something with namecase None => // do nothing }8Option in JavaOption<String> option = map.get(„hello“);if (option instanceof Some) { String name = ((Some) option).value();….} else {// option is none, there is no „hello“}Explicit handling of „NULL“ value necessaryOr:option.isSome() and option.value() without cast9For Trick for Option with IterableSometimes the none case needs no handlingFor and Iterable<T> can be usedFor automatically unwraps Option, does nothing in None caseNone returns EMPTY list, Some one element list with option valuepublic class Option<T> implements Iterable<T> { … }for (String name: getName(“hello”)) {// do something with name}10

Download
Better Strategies for Null Handling in Java

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Better Strategies for Null Handling in Java to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Better Strategies for Null Handling in Java as:

From:

To:

Share Better Strategies for Null Handling in Java.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Better Strategies for Null Handling in Java as:

Copy html code above and paste to your web page.

loading