WYSIWYG

http://kufli.blogspot.com
http://github.com/karthik20522

Saturday, June 2, 2012

Code Snippets - June 2012 Edition

I keep coming across scenarios where I need to check if an Object is truly empty and not just NULL. Part of the solution was to do perform conditional checks (if-then-else) on every property but it turned out to be very manual, high maintenance and time consuming work. Following is a quick and dirty way to check if a class is truly empty:


One of the most annoying part of statically typed programming language is the problem of NULL exceptions. Again "if-the-else" was the initial solution and following is a dynamic way of handling NULL values of any type. The following code takes in any property of an object (the object can be NULL by itself) and if the property is NULL it would spit out the default value that was provided.

Labels: ,