MVC & MVP

Discussion in 'ASP .Net' started by jack, May 5, 2008.

  1. jack

    jack Guest

    Hi guys,

    I wanted to know whats the difference between MVC and MVP pattern.

    Thanks
    jack, May 5, 2008
    #1
    1. Advertising

  2. First, I must add a caveat that this answer pertains to MS's implementations
    of these patterns. This is not that important, overall, but I am focused on
    how MVC and MVP are implemented in .NET (MVC Framework versus Web Client
    Factory), so there are some bits that may not apply to a generic MVC vs. MVP
    discussion.

    MVC uses three basic components, although you can put logic across many
    individual classes and even into separate libraries in separate assemblies.
    The three are Model (business model, which most commonly is a collection of
    business objects, which may be represeted as a DataSet in thinner
    implementations), view (UI) and controller (piece that marries the two.

    MVP adds a view interface, which separates concerns a bit more, at least in
    theory. The presenter and view are not coupled tightly as the view and
    controller are, at least in theory.

    Differences:
    For practical purposes, the controller is in charge of everything except the
    data (model) and the UI (view). This means the controller handles all
    interaction, the UI is just a veneer. It is responsible for correct
    rendering of the model it gets married to, but it does not handle events,
    etc. This also means all actions have to be declaratively linked back to the
    controller. That is MVC.

    With MVP, the UI is not tightly coupled to the Presenter (or at least not as
    tightly coupled). It can contain some UI related logic (not present in MVC)
    and different UIs can be used by the presenter based on actions. The
    controller can also do this, but the view must be bound to the controller to
    work.

    Why choose one over the other?
    In short, it is a simplicity versus extra power thing. And, since most of us
    do not need the extra decoupling of UI from presenter, the MVC pattern will
    fulfill our needs.

    NOTE: If you further separate the logic out into tiers, you can end up with
    an extremely thin controller and have models that are data representations
    without any type of access logic. Once you ahve done this, you can reuse
    this logic in MVC, MVP, Silverlight, WPF, Windows Forms, etc. The point
    being that the MVC Framework forcing of separation of concerns is not
    necessary if separation of concerns is your primary reason for adopting the
    pattern. Hope I did not muddy the water with this trip to the soapbox. :)

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog
    http://gregorybeamer.spaces.live.com/lists/feed.rss

    or just read it:
    http://gregorybeamer.spaces.live.com/

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "jack" <> wrote in message
    news:...
    > Hi guys,
    >
    > I wanted to know whats the difference between MVC and MVP pattern.
    >
    > Thanks
    Cowboy \(Gregory A. Beamer\), May 5, 2008
    #2
    1. Advertising

  3. jack

    bruce barker Guest

    MVC is the classic isolation of the view layer from the application
    layer. typically there is a message system to pass messages between the
    layers. This allows good separation of the UI layer from the application
    layer.

    Those that use TDD (test driven design) want less logic in the UI layer
    as its hard to write unit tests for UI elements (as few come with
    mocks). Thus MVP was born. It abstracts the UI behaviors (clicks, hides,
    setting UI properties) from the UI layer (event, etc) into their own
    layer. this allows units tests to be written for the behaviors. The MVP
    is just an extension of the MVC pattern.

    -- bruce (sqlwork.com)

    jack wrote:
    > Hi guys,
    >
    > I wanted to know whats the difference between MVC and MVP pattern.
    >
    > Thanks
    bruce barker, May 6, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. py
    Replies:
    3
    Views:
    865
    Chris Uppal
    Nov 6, 2006
  2. rmn190
    Replies:
    2
    Views:
    2,356
    Arne Vajhøj
    Jan 10, 2008
  3. jm
    Replies:
    1
    Views:
    284
    Michael Nemtsev [MVP]
    Jun 10, 2008
  4. Paulo
    Replies:
    3
    Views:
    477
    Peter Bromberg [C# MVP]
    Dec 4, 2008
  5. Steven Burn

    Warning: MVP.org is not a Microsoft MVP site

    Steven Burn, Jan 10, 2004, in forum: ASP General
    Replies:
    7
    Views:
    168
    Jeff Cochran
    Jan 12, 2004
Loading...

Share This Page