Lets see if there are some architechture people around here :)
Looking at code below... scrutinize this class and tell me whats wrong with its structure... what design pattern closely resembles it.. and how you can improve it? the code is provided in both C# and VB.NET so that it would be easier for those people who prefer {} and non-case sensitivity to look at it!
[C# Version]
public class Client
{
private string _name = string.Empty;
private string _email = string.Empty;
private string _company = string.Empty;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public string Email
{
get
{
return _email;
}
set
{
_email = value;
}
}
public string Company
{
get
{
return _company;
}
set
{
_company = value;
}
}
Client()
{
this.CreateClient();
}
Client(string clientName, string clientEmail, string clientCompany)
{
this.CreateClient(clientName, clientEmail, clientCompany);
}
private Client CreateClient()
{
return this.CreateClient(string.Empty, string.Empty, string.Empty);
}
private Client CreateClient(string clientName, string clientEmail, string clientCompany)
{
this.Name = clientName;
this.Company = clientCompany;
this.Email = clientEmail;
return this;
}
}
[VB.NET Version]
Public Class Client
Private _name As String = String.Empty
Private _email As String = String.Empty
Private _company As String = String.Empty
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Email() As String
Get
Return _email
End Get
Set(ByVal value As String)
_email = value
End Set
End Property
Public Property Company() As String
Get
Return _company
End Get
Set(ByVal value As String)
_company = value
End Set
End Property
Sub New()
Me.CreateClient()
End Sub
Sub New(ByVal clientName As String, ByVal clientEmail As String, ByVal clientCompany As String)
Me.CreateClient(clientName, clientEmail, clientCompany)
End Sub
Private Function CreateClient() As Client
Return Me.CreateClient(String.Empty, String.Empty, String.Empty)
End Function
Private Function CreateClient(ByVal clientName As String, ByVal clientEmail As String, ByVal clientCompany As String) As Client
Me.Name = clientName
Me.Company = clientCompany
Me.Email = clientEmail
Return Me
End Function
End Class
Any challengers?
Posted
02-07-2006 6:46 AM
by
keithrull