I recently had to help a developer colleague fix  a bug no one seemed to understand what the problem was. This is how it all started. The module he was writing was supposed to fetch emails from various email boxes and do some stuff with the unread emails. But inorder to do so he has to fetch credentials to the given mail boxes from a database databases. The only condition was that the table has a field called IsDeleted hence only those credentials not deleted should be fetched.

So on the development machine everything worked well but upon deployment to the UAT enviroment the damn thing just wont work. And so at that point it became a tale of numerous logging point since breakpoints wont help on compiled code. All this led us down to the point where we realized emails credentials werent being loaded at all reason being all values for IsDeleted were set to 0(zero).

It might be easy for someone to go on and blame the developer for missing out on such a thing but then again hang on. If given a choice of using the field name IsDeleted and IsActive what would you use? Consider the two snippets below written in c# lambda notation.

Where(x=>x.IsDeleted !=true)

Where(x=>x.IsActive == true)

The second statement is intuitive and makes thing quite tidy since you can easily go ahead and even condense that down to something like below.

Where(x=>x.IsActive)

This variable naming is as a result of attempting to derive language reserved key words. Another example is when dealing with Entity attribute value model  and one of the fields of an entity attribute is deciding whether is can be null. I have seen people use IsNullabe as opposed to my recommendation of the intuitive IsRequired.

 

Leave a Reply

Your email address will not be published. Required fields are marked *