I am trying to get my mind around OOP in C# Winforms, but I was wondering about something.
Lets say I’m making a chat system, using a Tcp Protocol. I need atleast the following:
– A TcpListener;
– A TcpClient;
– Something to parse/process the packet;
– A packet encryption system.
My question is, do I make classes called:
- Server;
- Client;
- Encryption;
- PacketHandler.
Or do I make 2 classes called:
– SendReceive; (Server and Client)
– PacketControl. (Packet handler and Encryption class)
Or do I just have it all wrong?
Are there any standards for choosing what you put in which class? -Links are welcome too.
Thank you for your time.
You might want to look at the solid principles or this article to find some design guidenlines. First you should ask for “responsibilities” and then try to assign them to classes. Try to write tests und you will see that smaller units (with single responsibility) are easier to test. If you need a unit that handles different things it might be composed of others (it’s a moderator between the smaller units then).