Every programmer that has some sort of social media presence has seen this image:
This is the perfect analogy of Null. With this in mind, you can actually utilize the use of Null. Null is actually a value to represent the absent of a value in a data type. The complete absence of a value is called a bottom type but that
"To Null or not to Null":
In most of my SQL tables, I always have a [DELETE_DATE] field. This is because I do not like to actually DELETE a record from a table. Instead, I will fill in a date (CURRENT_TIMESTAMP for MSSql).
This is where Null becomes important to my SQL environment. All of my stored procedures will always check to see if a date has been put into the [DELETE_DATE] field.
Another example in my SQL environment is using this to activate certain processes. I have a service that runs through different events based on statuses and dates. I will use a [PROCESS_DATE] to confirm that the record has been processed. You can utilize this field in order to "re-trigger" and event by putting a Null value on [PROCESS_DATE] for the record. The service will see this record and run the process again.
if(object.element) is the same as if(object.element === null). Any time code can be shortened and compressed is a plus in any programmers book.
I hope this sheds some light on the power of Null and its use as a value even though it represents the absence of a value... if that made any sense.
Top comments (0)