In my MVP app, my model (a service) returns a collection of
ISession pointers. Each pointer points to an object of a derived type
HttpsSession. The model (the service) knows nothing about any GUI, Views, Presenters, etc.
In my Presenter, I need to create and show a View, which should be different depending on the type of the session. How can I do this without using
dynamic_cast check on the pointers and without making
ISession -- and thus the model (the service) -- know about the existence of the GUI, MVP, etc.?
Note: In general, I have the same problem with writing the sessions' data into DB. The Presenter should call the database manager and it should write the sessions into the DB. But I don't understand how it can differentiate between the two types of the sessions without using the check on the dynamic type of the session. I just decided to choose one of the problems and ask here. Help me, please. I read and read about visitor, strategy, etc. patterns, but still cannot grab how developers normally do it.