When not true does not equal false; be very clear what you ask for
Posted in .NET Development,Web Development,eCommerce by Ray Schauer on December 9th, 2009
About two months ago I was sitting in a hotel conference room being trained on a new piece of software here at Bridgeline when an interesting philosophical question was raised. When something is not true, is it necessarily false? I suppose I should provide a little more background information for this question before getting into why this question is important.
The logic
When Boolean logic is used, the result should be very clear. True or False; that’s it. Or is it? The unfortunate problem with Boolean logic is that (depending on the situation), the value you are trying to determine doesn’t exist. In programming terms, it is NULL. Now, some programming languages make up for this by strongly typing variables. This means that Boolean variables are not allowed to be NULL, since it is neither True or False. However, this doesn’t play well once the user is given control of the options.
The problem
Let’s use a shopping cart application as our example. Merchandisers need to be able to define products and the attributes belonging to those products. In our example, the Crafty Widget Factory of Plumsville is setting up an online presence to sell their wares. They’ve decided they wish to create facets on their products based on several pieces of metadata. Our example will focus on the attribute ManagerSpecial.
ManagerSpecial is a Boolean variable set to True when the Crafty Widget Factory wishes to call out special attention to a product, or collection of products, on their home page. Additionally, it is used to create a facet within their product search. When searching for products, users of the Crafty Widget Factory’s website will be able to narrow down their results by choosing to only show products that are, or are not currently listed as ManagerSpecial.
The question
Now our question comes up. Since these are user definable attributes, it is quite possible the merchandiser at the Crafty Widget Factory of Plumsville did not make this attribute required for all products. Further, it is also possible that this attribute has not been assigned a value for all products. Given this, what do we display when asked to show all products where ManagerSpecial is not true?
- ManagerSpecial == False
- (ManagerSpecial == False) OR (ManagerSpecial == NULL)
Which option do we chose? In our case, the answer seems clear. We chose option 2. The reason is that if we chose option 1, we will be excluding all products which do not have the attribute set. In this case, we do not want this. However, what if the attribute in question wasn’t so cut and dry?
Why this is important; document examples
I bring this up as an example to illustrate how easy it is to confuse requirements and how tricky logic can be at points. When implementing any type of business rule, I find it incredibly useful to document examples of business logic along with the requirements. This allows all parties involved to focus and visualize possible outcomes of their chosen requirements. Without this, you may end up launching your shopping cart only to find products aren’t as easy to find as you thought they would be.

