Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4259546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:47:57+00:00 2026-05-21T05:47:57+00:00

It’s my first attempt at MVP, so please be patient :) In order to

  • 0

It’s my first attempt at MVP, so please be patient 🙂

In order to present a certain entity, I’m creating a view and a presenter.

I need to pass this entity to the view and the presenter somehow.

Is this the right way of doing it, in terms of passing around the DTO, or is there a smell?

class CustomerView
{
    public CustomerView(IPersenterProvider presenterProvider, 
                        CustomerDto customer)
    {
        _presenter = presenterProvider.ResolvePresenter<CustomerPresenter>(this);
        _presenter.Customer = customer;
    }
    ...
}

class CustomerPresenter
{
    public CustomerDto Customer
    {
        set 
        { 
            // Show customer details in the View
        }
    }
    ...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:47:58+00:00Added an answer on May 21, 2026 at 5:47 am

    I’m patient, really. You have a smell or two or three, indeed. The biggest one being the set-only property Customer on CustomerPresenter. The second one is that the view knows about the presenter – it really doesn’t need to. The third one is that the view knows about the DTO on the same level as it knows about the presenter. It shouldn’t – the presenter should tell the view what data to show.

    This is one of my humble takes on MVP and your specific issues.

    First, anything that a user can interact with, or just be shown, is a view. The laws, behavior and characteristics of such a view is described by an interface. That interface can be implemented using a WinForms UI, a console UI, a web UI or even no UI at all (usually when testing a presenter) – the concrete implementation just doesn’t matter as long as it obeys the laws of its view interface.

    Second, a view is always controlled by a presenter. The laws, behavior and characteristics of such a presenter is also described by an interface. That interface has no interest in the concrete view implementation as long as it obeys the laws of its view interface.

    Third, since a presenter controls its view, to minimize dependencies there’s really no gain in having the view knowing anything at all about its presenter. There’s an agreed contract between the presenter and the view and that’s stated by the view interface.

    The implications of Third are:

    • The presenter doesn’t have any methods that the view can call, but the view has events that the presenter can subscribe to.
    • The presenter knows its view. I prefer to accomplish this with constructor injection on the concrete presenter.
    • The view has no idea what presenter is controlling it; it’ll just never be provided any presenter.

    For your issue, the above could look like this in somewhat simplified code:

    interface ICustomerView
    {
        event EventHandler EditCustomerDetails;
    
        void Show(Customer customer);
    }
    
    class CustomerView : ICustomerView
    {
        Customer customer;
        readonly Form form; 
        readonly Button editCustomerDetailsButton;        
    
        public event EventHandler EditCustomerDetails;
    
        public CustomerView()
        {
            // UI initialization.
    
            this.editCustomerDetailsButton.Click += delegate
            {
                var Handler = this.EditCustomerDetails;
    
                if (Handler != null)
                {
                    Handler(this, EventArgs.Empty);
                }
            };
        }
    
        public void Show(Customer customer)
        {
            if (this.form.Visible)
            {
                // Update UI with new data.
            }
            else
            {
                // Initialize UI with data and then show it.
                this.form.ShowDialog();
            }
        }
    }
    
    interface ICustomerPresenter
    {
        void ShowView(ICustomer customer);
    }
    
    class CustomerPresenter : ICustomerPresenter
    {        
        readonly ICustomerView view;
        readonly IEditCustomerPresenter editPresenter;
        ICustomer customer;
    
        public ConfigurationPresenter(ICustomerView view, IEditCustomerPresenter editPresenter)
        {
            this.view = view;            
            this.view.EditCustomerDetails += delegate
            {
                this.editPresenter.ShowView(this.customer); // Edit
                this.view.Show(this.customer);              // Update
            };
    
            this.editPresenter = editPresenter;
        }
    
        public void ShowView(ICustomer customer)
        {
            this.customer = customer;
            this.view.Show(customer); // Assuming modal
            this.customer = null;
        }
    }
    

    That’s a rather simplistic view (sic!) on this matter, but it’ll maybe provide some hints.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to run a str_replace or preg_replace which looks for certain words
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT
I have a view passing on information from a database: def serve_article(request, id): served_article

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.