More an Implimentation Horror
-
0. This code is in the region of 10 years old and I only had VB (probably 5 at that point) to work with. 1. What the code does is, I think sound. In each class these variables are defined:
Private mlErrNumber As Long '** Standard Variable for Error Trapping **
Private msErrDescription As String '** Standard Variable for Error Trapping **
Private msErrSource As String '** Standard Variable for Error Trapping **Then in any function or sub
mlErrNumber = 0
clears the error state. Not bad so far, slightly ott, but not bad. So when an error occured, this was called to persist the error state to be used by any calling classes:Private Sub SetError(ByVal alNumber As Long, _
ByVal asDescription As String, _
ByVal asSource As String, _
ByVal asLocation As String)
'================================================================================================
' Sub : SetError
' Arguments : alNumber Number of the error
' asDescription Description of the error
' asSource Source of the original error (Added 1.00.0001)
' asLocation Location of the error
'------------------------------------------------------------------------------------------------
' About : Sets the current error.
' If mlErrNumber is already set, it just appends to the location
'================================================================================================On Local Error Resume Next If mlErrNumber = 0 Then mlErrNumber = alNumber msErrDescription = asDescription If asSource = APP\_TITLE Or \_ asSource = asLocation Or \_ asSource = "" Then msErrSource = "" Else 'It's someone else's error, record where it came from msErrSource = " " & asSource End If Call gObjCommon.SendToLog("E", mlErrNumber, 1, CLASS\_NAME, asLocation, \_ msErrDescription & IIf(msErrSource = "", "", " \[Occured in" & msErrSource & "\]")) End If If asLocation <> "" Then msErrSource = "." & asLocation & msErrSource End If
End Sub
The horror? Appart from the language, why didn't I see this as being repeated? It's in ~50 seperate classes!
Panic, Chaos, Destruction. My work here is done.
-
0. This code is in the region of 10 years old and I only had VB (probably 5 at that point) to work with. 1. What the code does is, I think sound. In each class these variables are defined:
Private mlErrNumber As Long '** Standard Variable for Error Trapping **
Private msErrDescription As String '** Standard Variable for Error Trapping **
Private msErrSource As String '** Standard Variable for Error Trapping **Then in any function or sub
mlErrNumber = 0
clears the error state. Not bad so far, slightly ott, but not bad. So when an error occured, this was called to persist the error state to be used by any calling classes:Private Sub SetError(ByVal alNumber As Long, _
ByVal asDescription As String, _
ByVal asSource As String, _
ByVal asLocation As String)
'================================================================================================
' Sub : SetError
' Arguments : alNumber Number of the error
' asDescription Description of the error
' asSource Source of the original error (Added 1.00.0001)
' asLocation Location of the error
'------------------------------------------------------------------------------------------------
' About : Sets the current error.
' If mlErrNumber is already set, it just appends to the location
'================================================================================================On Local Error Resume Next If mlErrNumber = 0 Then mlErrNumber = alNumber msErrDescription = asDescription If asSource = APP\_TITLE Or \_ asSource = asLocation Or \_ asSource = "" Then msErrSource = "" Else 'It's someone else's error, record where it came from msErrSource = " " & asSource End If Call gObjCommon.SendToLog("E", mlErrNumber, 1, CLASS\_NAME, asLocation, \_ msErrDescription & IIf(msErrSource = "", "", " \[Occured in" & msErrSource & "\]")) End If If asLocation <> "" Then msErrSource = "." & asLocation & msErrSource End If
End Sub
The horror? Appart from the language, why didn't I see this as being repeated? It's in ~50 seperate classes!
Panic, Chaos, Destruction. My work here is done.
VB kind of forced all of us to a number of little implementation horrors, what with fake OOP and all. :-D I had my share of VB back in the day, and I'm happy it's over! When I have to maintain some of my old code from the 90's I still shiver at some horrors I see. It sure was partly my fault, but I'm convinced VB did its part. We will probably enter yet another phylosophical/religious debate if we start arguing about goods and bads in old VB, but I think (hope) everybody will agree that even if it did have a sense in its day, it was just EVIL. ;P
2+2=5 for very large amounts of 2 (always loved that one hehe!)