CS and the City Sean Lynch

Offensive and Defensive Coding

Today’s coding practices tip (as if this is a regular thing) comes from Michael Feathers at Artima Developer. He writes an article on the perils of playing pass the hot null in your code:

“[using null checks] …just means that you’re dealing with bad code: you’re dealing with code where people are actively making extra work for themselves and making code brittle in the process.”

Read the entire piece here. Something I’ll have to consider. I’d like to see him flesh out his argument for using null objects such as empty arrays and strings rather than nulls. I see his point that it can help handle the exceptional case graceful, but I think that nulls may have their proper place. It’s easier to check for a null than to check if a string .equals(“”).