R
Robert Scheer
Hi.
I could not find an specific group on patterns, so I am posting
here...
We are trying to develop some patterns to be used on .NET development.
An independent consultant recommend us that we start by using the
Class Factory pattern to help in isolate our code. Our team though, is
complaining that the design is complicated to develop with. I would
like your opinion about this design. Following is a sample of the
recommendation:
Public Interface IUser
Function ReadDetail(ByVal user As String) As String
End Interface
Public Class UserFactory
Private Sub New()
End Sub
Public Shared Function GetInstance() As IUser
Return User.GetUserInstance
End Function
End Class
Friend Class User
Implements IUser
Private Shared _user As User
Public Shared Function GetUserInstance() As User
Try
If _user Is Nothing Then
_user = New User
End If
End Try
Return _user
End Function
Public Function ReadDetail(ByVal user As String) As String
Implements IUser.ReadDetail
'Code goes here
End Function
End Class
On the client side, we have to call the User implementation through
its interface always:
Dim u As IUser = UserFactory.GetInstance
Dim s As String = u.ReadDetail('Robert')
Is it the recommended way to work? Does it allow for inheritance?
Utilities classes should also go this way?
Your opinion is really appreciated!!
Regards,
Robert Scheer
I could not find an specific group on patterns, so I am posting
here...
We are trying to develop some patterns to be used on .NET development.
An independent consultant recommend us that we start by using the
Class Factory pattern to help in isolate our code. Our team though, is
complaining that the design is complicated to develop with. I would
like your opinion about this design. Following is a sample of the
recommendation:
Public Interface IUser
Function ReadDetail(ByVal user As String) As String
End Interface
Public Class UserFactory
Private Sub New()
End Sub
Public Shared Function GetInstance() As IUser
Return User.GetUserInstance
End Function
End Class
Friend Class User
Implements IUser
Private Shared _user As User
Public Shared Function GetUserInstance() As User
Try
If _user Is Nothing Then
_user = New User
End If
End Try
Return _user
End Function
Public Function ReadDetail(ByVal user As String) As String
Implements IUser.ReadDetail
'Code goes here
End Function
End Class
On the client side, we have to call the User implementation through
its interface always:
Dim u As IUser = UserFactory.GetInstance
Dim s As String = u.ReadDetail('Robert')
Is it the recommended way to work? Does it allow for inheritance?
Utilities classes should also go this way?
Your opinion is really appreciated!!
Regards,
Robert Scheer