Avoid Billion Dollar Mistake in your code

Avoiding Billion Dollar Mistake in your code

Different challenges arises from been an  influential computer scientist. One of  the old greatest computer scientist who invented “null” “Tony Hoare” said , one of my billion dollar mistake is the invention of null, he made the mistake without seeing the billion dollars.

No doubt , null is use to represent the  absence of a value which blows up the code in the nearest future with the dreaded NullPointerException. Using null can thus be replaced with Optional function , using Optional means

1. You are documenting the values that  are meant to be absent in class API

2. Checking whether a variable is null in  order to avoid possible bugs
Example:

String message = null;  message = "Avoid billion dollar mistake in your code"

Optional<String> optionalMessage = Optional.of(message)

Using optional means you are checking if  the value is null or not.

I hope this help… (:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: