While poring through some VB .Net code, John noticed some odd things in their datamodel. For example, a different process would scan files, and log any “suspicious” files into a database. The program John supported would then report on that data.
One of their classes had a property which looked like this:
Public ReadOnly Property SuspectedItem As SuspectFileDataItem
Get
Return Me
End Get
End Property
Now, there are many reasons why a method might return a reference to the instance- builder patterns are often a nice way to describe things in code. But a property returning its own instance, well… that doesn’t make sense at all. “Give me the thing I already have.”
It didn’t help that it was also used: item.SuspectedItem.someProperty()
was scattered all through the codebase.
Then again, perhaps this code is self describing. I suspect a lot of things about this item. I also have some suspicions about what substances this developer may or may not consume which lead to this code.
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!