in a classic movie They Livethe main character is a drifter named “Nada”. there is nothing. Žižek derives a lot of meaning from this word, and above all it is a funny rant.
But Nada also appears in other places. For example, I found the following code: JMM.
Dim Nada As Boolean = False
cn.Open()
Using r As SqlDataReader = rs.ExecuteReader
If r.HasRows.Equals(False) Then Nada = True
End Using
cn.Close()
Return Nada
As with bad VB .NET code, this is pretty mild. But like Žižek, we can overanalyze it and find more meaning.
First…start with colloquial variable names. Nada
. Again, I expect the following: there is nothingbut it is do not have It doesn’t represent anything. This actually represents something very important. That is, do the records exist in the dataset, or do they not exist? Describing this as nothingness, emptiness, and meaninglessness is misleading and confusing.
Then you will see the act of opening cn
, connect to the database, and later close it, without any error or exception handling along the way. If something goes wrong with this process, open connections are not cleaned up. This can be solved by simply using Using
I created a connection using keywords but they didn’t do that. However, it is Close
The function is called without having to explicitly execute it, even if an exception occurs.
But the real “heart” of this indescribable thing is its mainline tortured logic. If r.HasRows.Equals(False) Then Nada = True
This is a standard anti-pattern and is commonly seen. A sign that someone doesn’t understand boolean values and their true meaning.It can be more easily expressed as Nada = Not r.HasRows
Or simply Return Not r.HasRows
.
But there’s a hint of something deeper here. Run the query to see if that’s the case. there is a lineThis means you are requesting actual data from the database. Data we don’t need or use. The correct query here would be: COUNT
One row is returned and we examine its contents. COUNT
Check how many meaningful rows there are in the database.
We find ourselves staring at code that names variables void, but upon inspection we discover that the true void is the mind that created this code. Empty, nothing to see, nothing to signify, nothing to signify. I can’t say anything.
BuildMaster allows you to create a self-service release management platform that allows different teams to manage applications. Let’s find out how!