开发者

Design pattern suitable for messenger like ICQ, skype, pidgin..[WPF-C#]

I need advance I am newbie in design pattern. I am developing messenger like ICQ, Skype, Pidgin-this is school project, it does not work with ICQ, Skype protocol, it works with own protocol.

This messenger provides this functionality{methods}:

*Log on on sever *Load contact list *Send message *Recieve message *Send comment *LogOff

These methods are grouped in one class called XCommands.

User data(ID, password, cookies, some settings) are grouped in class called XAvatar.

All methods of cl开发者_如何学JAVAass XCommads accepts as argument object type of XAvatar + other arguments.

I think this is very bad design. I search with google one hour but I find any solution for my problem.

Could someone advise what design pattern would be suitable, some UML. Thank you very much for any advice.


Remember that a design pattern is a common way to resolve a common problem:

  • "how can my code use different algorithms under different circumstances at runtime?" (strategy pattern)
  • "how can I implement a complex series of behaviors so that certain subclasses can override certain steps in the series, but inherit others?" (template method pattern)

There's a great many design-time questions which cannot and shouldn't be answered using a pattern:

  • "what pattern should I use to design a User object?" (too granular - doesn't really specify a common problem)
  • "what pattern should I use to build an IM client program?" (too abstract - design patterns address common specific problems, not entire software designs)

You've made a good start - you've represented your business data as objects (or in this case, 1 object: XAvatar) and you've defined a service API (XCommands). As you continue design/development from this point, you'll hit some more specific snags or problems. Very likely, some of those will be common problems many other developers have encountered before: THAT'S when design patterns will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜