Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

When reading examples across the Internet (including the MSDN reference) I have found that code examples are all doing the following type of thing:

public class FooViewModel : BaseViewModel {
    public FooViewModel(FooController controller) {
        Controller = controller;
    }
    protected FooController Controller { get; private set; }

    public void PerformSuperAction() {
        // This just routes action to controller...
        Controller.SuperAction();
    }

    ...
}

and then for the view:

public class FooView : BaseView {
    ...

    private void OnSuperButtonClicked() {
        ViewModel.PerformSuperAction();
    }
}

Why do we not just do the following?

public class FooView : BaseView {
    ...

    private void OnSuperButtonClicked() {
        ViewModel.Controller.SuperAction();

        // or, even just use a shortcut property:
        Controller.SuperAction();
    }
}
share|improve this question
    
You may find the answer to this question helpful. programmers.stackexchange.com/questions/254005/… –  Cameron McKay Aug 23 '14 at 4:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.