Monday, November 12, 2012

What is null?

What does "null" mean?  You should read null/NULL/nil in the following manner:

"I am not making a statement about the value - it does not exist."

Null is not zero.  Zero is a number.  For languages like Java that support boxing, smalltalk that only has objects, pointers to numeric values, etc, a NULL means THERE IS NO VALUE.  You are not saying it's zero.

Null is not false.  A boolean is a value.  If I'm checking a boolean variable "foo" and it's null, it is not true or false.  If "foo" is false, it has a value.  If "foo" is true, it has a value.  If it's null, then the value has not been set.

Does that mean I have to write 'ugly' code like if(foo is not null and foo)?   That's not ugly code, it's explicit.  if(foo) might work but you're not being clear.  If you intend foo to be false, then set it as false: "foo = false; if(foo) ... ."

There are many subtle bugs that occur because everyone assumes a value had been set for foo, but in fact no value had been set.  It just happens that in your language, null, false and 0 happen to be the same thing.

Sunday, January 15, 2012

A Library for RSS Feeds

I really would like to move to mobile development.  So much so that I have a strategy.  If I can't do so in my current position, I will continue to build up a series of libraries to help people build iOS applications.  Why iOS?  Just personal preference, really.  I'm also interested in Android and periodically poke around in there as well.  Rather than over analyzing which platform should I write code for, I decided to just write code.  I've got a Mac and an iPhone, so I'm good to go there.

So, my first published library is an RSS 2.0 feed reader for iOS called RssKit.  I'm working on taking the first complete application I wrote for the iOS (but never pushed to the app store), and breaking it down into individual libraries that might be re-usable.  The first is reading RSS 2.0.  Next will probably be downloading data in CSV format from a URL (although a little more flexible than that).  Third will probably the the ability to draw a candlestick chart for a stock.