Lesson #1 from the real world

Often it can be tempting to let a single variable have multiple functions. Such as letting the absence (or null value) denote some boolean decision. An example of such could be an object denoting feedback. Here, the initial attempt to model the object could be to let the absence of the userId field denote whether the user wants to be notified about feedback received.

However, this is a bad idea. When another developer 5 months later arrives and is tasked with setting up reminders for feedback requests, she will struggle finding out who the user asking for feedback is: The uid field on the feedback object is optional (nullable) and the comment says that absence means that the user does not wish to receive notifications. However, it is impossible to send the reminder without knowing who requested feedback.

Now the field has one more meaning: if defined, there will be sent a reminder and the requester will be notified about new feedback, otherwise no notification and no reminders are sent.

Please remember to always have compassion for other programmers and becurious about lessons.An obvious point for one programmer might be an epiphany for another.

Over and out Mads