I have the following code (much simplified for this post). Note that
SessionKey uses DataAccess, and DataAccess requires SessionKey in it's
constructor.
Public Class SessionKey
Public IsValidSession as Boolean
Sub New(UserName, Password)
' Create session, including calls on DataAccess
' to validate username/password
IsValidSession = True
Dim DataAccess as New DataAccess(Me)
' Set IsValidSesion = False if usercode/password is invalid.
End Sub
End Class
Public Class DataAccess
Sub New(SessionKey)
If Not SessionKey.IsValidSession then
Throw New Exception ("Not a valid session!")
End If
End Sub
Function ExecuteSQL(SQL) As DataSet
'execute some SQL
End Function
End Class
It works great, but does this qualify as a circular dependency?
What's wrong with having a circular dependency in the first place?
Memory leaks? Performance problems? I understand that circular
dependencies can be a symptom of poorly designed class libraries, but
in this case, the class design seems fine. Should I take the time to
create a 3rd class that SessionKey and DataAccess inherit from?
Thanks,
Henry