views:

15

answers:

1

Hi, I am developing a desktop client app for web chat. Something that is similar to icq, pidgin, skype, etc.

The client app communicates with the server through POST and GET.

Client app has these methods:

  • login
  • logout
  • loadFriendList
  • SearchUser
  • AddFriend
  • SendMessage
  • LoadMessages

I would like to use a design pattern for this winforms app. I am a newbie in patterns and I need advice on which design patterns are suitable for this application.

Sorry for my English. Any advice on how to organize application code with design pattern?

Thank everybody

A: 

This question is more than a little broad/vague, so I'll answer based on responding to messages.

You could go with a message pump-type pattern, similar to how Win32 operates, where you generally have a single method where you handle the messages through a switch statement. Though if it gets too big, I would put the actual logic in separate methods, and have that single method just call whatever method is appropriate.

Another pattern which is more "C#-esque" would be to use events, one for each message type. You could also add a general MessageReceived event that would be fired for any message received, in addition to individual message types.

nasufara