I've been attempting to fully understand the Model View Presenter pattern as it applies to C#. I have one question I can't wrap my head around.
In many examples, I noticed that model is defined as static and is constructed in the Presenter base class (often a generic class).
How does one have multiple model classes in that case? From my understanding, every presenter created will only be able to reference a single model class.
The example I'm looking at now can be found here: http://wesaday.files.wordpress.com/2009/01/finalzip.doc (rename to .zip). It's from this tutorial: http://wesaday.wordpress.com/2009/01/30/winform-model-view-presenter-part-v-the-view/
The guess the overall issue I'm having is seeing how examples like the one above adapt to a working application with multiple views/presenters/models.
This is presumably just a simplification in order to avoid incorporating a complete IoC implementation in the sample. An MVP triad is usually represented by stand-alone (i.e.: not static, singleton, or otherwise shared) instances at runtime. In some exceptional cases, a model may be a shared instance, but this is usually the exception rather than the rule, and it's generally only the case for read-only forms or controls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With