The question of booleans is interesting.
A boolean is often used as a return value to denote the success or failure of a method. If we were not interested in the processing result, the method would normally have have a void (or null) result.
I have now come to the view that this is an inappropriate use of the boolean, for a number of reasons (which I hope to elucidate in separate pattern when I've got my thoughts together).
However, the reason I'm talking about it here is that I believe there are naming implications for the method depending upon what is intended.
If the objective of the method is to deliver a boolean result such that it can be assigned to a LValue (that is, we are NOT returning the processing status), then it should follow the naming rules for a boolean variable or property. The naming rules should be such that the name is that of a fact (and thus in the passive voice): TaggedValueWasFoundInElement(Tag, Element), .IsValidForPeriod(Commencement, Termination). Naturally, this would allow it to be used directly in the if statement conditional, without further effort:
If TaggedValueWasFoundInElement(NameTag, Element) Then
'Process Tag value
End If
if (!Cheque.IsValidForPeriod(Commencement, Termination))
{
//Bounce it...
}
I use a different process to handle processing results. I use a HResult concept to provide more information regarding the processing. If I need to take appropriate action I can test to the required level. I provide wrappers such as bool SUCCEEDED(HResult), bool FAILED(HResult) etc. This allows me to implement multi-state logic very easily. The method is named using an active (verb based) name - such as: FindUDXMLStructure(string name), SetLogicalOnlyInferenceOnEntity(value As Boolean)
Thoughts?
Paolo