Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should the View rather not know about Presenter? #4

Closed
noseratio opened this issue Aug 20, 2021 · 1 comment
Closed

Should the View rather not know about Presenter? #4

noseratio opened this issue Aug 20, 2021 · 1 comment

Comments

@noseratio
Copy link

First of all, many thanks Mart for putting this repo together, very useful.

The comment I have, should the View rather not know anything about Presenter? Here you have a reference to CustomerPresenter inside ICustomerView:

Presenter.CustomerPresenter Presenter { set; }

I'd expect to have no tight coupling here. Rather, some sort of event sources or observables that the Presenter would be subscribing to. Something similar to what Mark Heath is doing in his related article:

interface ICustomerView
{
    // ...
    int SelectedCustomer { get; set; }
    // ...
    event EventHandler SelectedCustomerChanged;
}
@mrts
Copy link
Owner

mrts commented Aug 24, 2021

Good point, thanks for bringing this up! Sure, using events is one excellent way of doing it.

However, there's a big difference between tight coupling and tight cohesion (or integration), where the former is undesirable and the latter desirable. When the view invokes the presenter directly, then the role and function of the presenter is clear and explicit at a glance, like it is for example in CustomerForm. In case of events the integration is more vague and you would need to trace down the flow of events to reason about the interaction of the view and presentation layers.

So, in my opinion there is a benefit of tight cohesion at the expense of a little coupling when the view knows about the presenter. You have to pick your wins and losses, every option comes with its pluses and minuses.

@mrts mrts closed this as completed Aug 24, 2021
@mrts mrts pinned this issue Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants