Consider the design of a ChatRoom Whenever a Client sends a

Consider the design of a ChatRoom. Whenever a Client send()s a message, it should be recorded by the ChatRoom and also sent to each and every Client. Which two patterns are likely to be key to this design? Why?

Solution

for the above problem, I would recommend the mediator pattern.This pattern provides a mediator class which normally handles all the communications between different classes and supports easy maintenance of the code by loose coupling.

Mediator design pattern is very helpful in an enterprise application where multiple objects are interacting with each other.
So, your chatRoom will be the mediator in this design pattern.
NOTE : go have a thorough look on mediator design pattern.

You can also use the observer pattern , as you have many clients in your chat application. Message sent from one client needs to be sent to many, So, in the scenarios where there is one-to-many relationships between the objects,such as if one object is modified, its depenedent objects are to be notified automatically ; the observer design pattern is used,
NOTE : go have a thorough look on observer design pattern.

Consider the design of a ChatRoom. Whenever a Client send()s a message, it should be recorded by the ChatRoom and also sent to each and every Client. Which two

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site