samedi 6 octobre 2018

Exposing a stream or using the observer pattern

I have a class as follows

class Controller {
    Stream<Requests> stream;
}

and other listener classes that want to know about requests from the stream and act according to them.

I wanted to know what is better in terms of OO principles:

  1. exposing the stream and letting listener classes listen to it
  2. Adding listener classes as observers and notifying them when a new request arises from the stream?
  3. maybe a different solution that i didn't mention here?

I don't think it matters but I am using dart, question probably applies to any oo language.

Aucun commentaire:

Enregistrer un commentaire