This is an anti-pattern.
vbnet
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj IsNot Nothing Then
If obj.GetType Is Me.GetType Then
Return Me._description.Equals(CType(obj, EventItem)._description)
Else
Return False
End If
Else
Return False
End If
End Function
this is better and gives the same result same
vbnet
Public Overrides Function Equals(ByVal obj As Object) As Boolean
Dim ReturnValue As Boolean = False
If obj IsNot Nothing AndAlso obj.GetType Is Me.GetType Then
Return Me._description.Equals(CType(obj, EventItem)._description)
End If
Return returnValue
End Function
The anti-pattern is called the arrow anti-pattern and you can find plenty of things about it on the net and how to avoid it.
Here are some good ones.
[
Flattening Arrow Code]1 by Jeff Atwood
Anti-Patterns and Worst Practices – The Arrowhead Anti-Pattern by Chris Missal
Of course the design anti-pattern in the above code doesn’t only have that as a disadvantage. The biggest disadvantage is that ncover will never give you 100% code coverage 😉 because the end-ifs will never be reached.
That in itself is a good reason not to write it. Because you are writting code that will never be used 😉
Disclaimer: Of course it will never compile if you leave out the end if.