Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I developing a Skype-Clone chat application, and wanna use Mediator Pattern or Observer Pattern.

But, what is the different between those 2 patterns ? After hours of searching and reading, still confusing about it, so :

1. What is the main different between Mediator and Observer ?

2. With a chat application, which one is the best choice ?

3. If my question is wrong, please give me some advises how the real-world do with chat applicattion (architect, pattern...).

P/s: The main idea of my application is :
- User can view who is online
- User can communicate (chatting, sending files...) with another Users in seperate window
- If more than 2 Users in 1 "Chat-Room", when 1 User send data (text, file...) to Server, Server will "broadcast" those data to another Users in the Room (except sender)

I know how to "communicate" between Clients, but how the real-world do it ? Please help me, and thanks for reading.
Posted
Comments
Rob Philpott 28-Jul-14 4:57am    
Why do you want to use these patterns? It's a dangerous process deciding what pattern you want to use then trying to get your system to fit into it.

My recommendation is to sit down and think how it will work - the patterns form naturally.
Nguyen.H.H.Dang 28-Jul-14 5:26am    
Thanks for replying !

I have done the application before, but my code is hard to maintenance and upgrade and without an architect. So, i wanna re-write the application, and wanna learn how to do it the right way. Googled about it, and found some free sources using those 2 patterns.

May be i made a beginner's mistake when trying to "implement a pattern". But, can you give me some advise about where should i begin ?

Thanks again for reading, and sorry for my bad English.
Suvabrata Roy 28-Jul-14 6:07am    
So you need suggestion how you should code to build a chat application?
Is it Desktop or web?
Nguyen.H.H.Dang 28-Jul-14 7:38am    
Thanks for replying :D

Its a Desktop Application, can you give me some advises ?
Suvabrata Roy 28-Jul-14 9:43am    
Hi,

Features Of Chat App:
1. Text Communication
2. Image Share
3. Video Share (Limited Size)
4. One to One Chat
5. Group Chat
6. Status Share
7. Smiley Share
8. Messenger to Text Message to Mobile *

Those are the features of a Chat application in current days (Some application provide more then that).

Now what kind of environment you have.

1. Mobile Compatibility required
2. Web Integration required
3. Desktop Integration required
4. what kind of infrastructure you have? ( Most importent part first analyze it then proceed because if you develop something that dos't support your infra it dose not help any one)

Load how many user's you are prospecting
1. 100 - 300
2. 301 - 1500
5. 1501 - 4000
6. 4001 - *

this sections are dependent on your requirement so first measure those

1 solution

The mediator pattern provides an interface between two services so that they can develop independently - if you are depending on a service that is developed by someone else (such as an API) then using a mediator pattern makes sense.

The observer pattern is a way of state changes in one thing being notified to a list of things (observers) that need to be notified.

These patterns are not mutually exclusive - you could, for example use the observer pattern and have your notifications go through a mediator where they need to be sent to an external api. I would definitely recommend this if you want to use an SMS provider for off-app messages.

As a general rule, patterns exist to solve problems so the best thing to do is work out the types of problem you are likely to encounter and then pick the pattern(s) appropriate to solving them. Treating a pattern as an architecture is not a good idea (imo).
 
Share this answer
 
Comments
Nguyen.H.H.Dang 30-Jul-14 9:14am    
Thanks for the solution :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900