I'm refactoring a WinForms (.NET 4) application that makes use of a TabControl to contain a UserControl--the UserControl is instantiated in each TabPage with the end result being editors in each tab. These are editing a collection of items that ultimately feed into the object being edited by the form as a whole.
As an example class structure:
class School
string Name
string Address
- Collection of
Course
s, each with several appropriate fields (Department
,Name
, etc.)
(It's not actually a school-related application, but the metaphor works.)
Visually, the set of UserControls manages the Course
es, while the parent Form handles the School
information.
Right now, I have a presenter for the Form/School, and a presenter for the UserControl/Course, with a view for each. The School's presenter needs to control some information for the Courses, however. For instance, options selected for one Course restrict options in the others. The School
model is handling the calculations of that, but it needs to get to the Course's presenter.
I'm not having much success in finding examples of this type of relationship in MVP discussions, and this is my first time taking an MVP approach. What are good options for handling this? Is it appropriate for the School's presenter to have a collection of the Course's presenters to represent the set? Should the School's view be holding a collection of the Courses' views? (The final UserControls have to end up attached to the form somehow and somewhere, right?)
My main goals are (unsurprisingly) increasing testability and maintainability, and major sources in the process so far have been Michael Feathers' "The Humble Dialog Box" and Jeremy Miller's "Build You Own CAB" series.