Option 1: (without testability)
MVP
Application Controller
- Each form has its own controller
- Controller interact with its form via its public interface (property, event, methods)
- For forms, other than the public interface (property, event, methods), everything else is private. (not accessible by its own controller)
- User Controls do not have its own controller. Hosting form interact with its user controls via public interface of the controls (property, event, methods)
- User controls is private to hosting form, the controller of the form does not have the knowledge of the user controls it hosts.
- Forms has no knowledge of their respective controller
- For each business process (each transaction), there is a Business Process Controller. BPC complete its process by interact with public interface of Controllers.
Benefits
- “Separation of Concerns” leads to cleaner code and easy to maintain.
- Reusability on User Controls
- Reusability on forms / controllers
Option 2 (with testability)
- Each form has its own Presenter. Each form implement a specific interface (e.g IMyForm and MyForm)
- Presenter interact with its form via the interface the form is implemented
- For forms, other than the implementation of the interface, everything else is private. (not accessible by its own controller)
- User Controls do not have its own Presenter. Hosting form (or control) interact with its user controls via public interface of the controls (property, event, methods)
- User controls is private to hosting form, the Presenter of the form does not have the knowledge of the user controls it hosts.
- Forms has no knowledge of their respective Presenter
- Each Presenter implement a specific interface IPresenter
- For each business process (each transaction), there is a Business Process Controller. BPC complete its process by interact with the interface of the Presenters.
Benefits
- Separation of Concerns, cleaner code, easy to maintain
- Reusability of user controls
- Reusability of Presenters / forms
- Testability on Presenters
- Testability on Business Process Controller
Option 3 (with testability on user control logic)
- With everything described in option 2
- Make a presenter for each user control,
- Make user control implement its own interface (MyControl implements IMyControl)
- My the presenter of the user control interact with user controls via its interface
Additional benefits:
The user process logic for user controls is also unit testable.
No comments:
Post a Comment