RSS

Tag Archives: null

#10 Indicate what happens when function can’t return value

There are many functions which take a value, go and look for something, and return an object. If the object is found it is returned, but if it is not found, what do you do?  There are two possibilities, either return a null, or throw an exception.  Often, there is justification for having two methods: one that returns a null, and one that throws an exception.  But how do you tell them apart?  This post suggests a possible naming convention. Read the rest of this entry »

 
Leave a comment

Posted by on October 10, 2011 in Coding

 

Tags: , , ,

#7 Functions Returning Collections, should never return null

A function that returns a collection, such as a list of all files in a folder, all sections on a page, or all attachments on a web site, should never return null.  It is a simple rule, and if followed reduces the complexity of the calling code. Read the rest of this entry »

 
Leave a comment

Posted by on October 5, 2011 in Coding

 

Tags: ,