K
Kuma
Beginner question. Are there any advantages or disadvantages to using
a custom data object to group logically linked objects vs using simple
fields? For example (don't beat me up too much it's an example).
Instead of this:
public class Chat
{
private string Message { get; set; }
private string Name { get; set; }
private DateTime When { get; set; }
public Chat(string a, string b, DateTime c)
{
Message = a;
Name = b;
When = c;
DoSomeThing1(A, B, C);
DoSomeThing2(A, B, C);
DoSomeThing3(A, B, C);
}
}
Would there be a reason why using the ChatMessage object below is good
or bad?
Is it just a personal preference?
public class ChatMessage
{
private string Message { get; set; }
private string Name { get; set; }
private DateTime When { get; set; }
public ChatMessage(string a, string b, DateTime c)
{
Message = a;
Name = b;
When = c;
}
}
public class Chat
{
public Chat(string a, string b, DateTime c)
{
ChatMessage msg = new ChatMessage(a, b, c);
DoSomeThing1(msg);
DoSomeThing2(msg);
DoSomeThing3(msg);
}
}
a custom data object to group logically linked objects vs using simple
fields? For example (don't beat me up too much it's an example).
Instead of this:
public class Chat
{
private string Message { get; set; }
private string Name { get; set; }
private DateTime When { get; set; }
public Chat(string a, string b, DateTime c)
{
Message = a;
Name = b;
When = c;
DoSomeThing1(A, B, C);
DoSomeThing2(A, B, C);
DoSomeThing3(A, B, C);
}
}
Would there be a reason why using the ChatMessage object below is good
or bad?
Is it just a personal preference?
public class ChatMessage
{
private string Message { get; set; }
private string Name { get; set; }
private DateTime When { get; set; }
public ChatMessage(string a, string b, DateTime c)
{
Message = a;
Name = b;
When = c;
}
}
public class Chat
{
public Chat(string a, string b, DateTime c)
{
ChatMessage msg = new ChatMessage(a, b, c);
DoSomeThing1(msg);
DoSomeThing2(msg);
DoSomeThing3(msg);
}
}