jeudi 16 septembre 2021

Which design pattern best describes the behavior in my example?

The following fake example is a class that facilitates a polling process, stores the results, and saves it to a DB. My understanding is that this would be considered a Mediator pattern as it is facilitating the communication between objects that would otherwise be coupled without it. Is this accurate or would there be another pattern that explains this behavior better? Thank you!

public class StatusPoller
{
    public void Poll()
    {
        foreach(User user in users)
        {
           string accessToken = oAuthClient.Authenticate(user);   // Authenticate
           List<status> statuses = pollingClient.PollStatus(accessToken);   // Poll for status
           Store(statuses);   // Store statuses in DB
        }

        Message.Dispatch(5)  // Dispatch a new message on a delay
    }
}

Aucun commentaire:

Enregistrer un commentaire