473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Practical Benefits of MVC or MVP Patterns

Okay, I just finally figured out the Model View Presenter pattern as
presented by Martin Fowler
(http://www.martinfowler.com/eaaDev/M...resenter.html). I even got a
small model of it working in a Windows Forms app I created from scratch.
Pretty cool how the form is sitting there and gets populated from the
Presenter - and the Form is pretty dumb (i.e., it really has no clue where
it's getting populated from.).

I understand that creating a "dumb" UI layer (per MVP and similar patterns)
has the benefit of allowing us to have multiple forms that all get populated
from the same Presenter. Great. What if I have no intention of ever doing
that (i.e., I have good reason to think I'll never have multiple screens
presenting the same model/data; or I'll likely never be providing both a Web
UI and Windows or Mobile UI). Should I still implement MVP or some other
means of separating the UI (Form) from the underlying data?

Please understand that I already know the answer is likely "yes, of course
you should separate it all out."

But what I would really appreciate are some specific benefits of doing such
separation and concrete examples if possible (reasons beyond the theoretical
"if you ever need to it will all be ready to go.").

Thanks for your time and consideration.

-Jeff

Feb 16 '06 #1
5 9481
Hi Jeff,
no example here but the nice benefit of this pattern is that because your
UI is mainly dumb and the bulk of your code lives inside the controller and
model it makes your code easier to unit test. Because the controllers are
just classes they can be unit tested just like any other class, the more
code you have in the GUI the more you have to test through the GUI which is
difficult, you either have to do it by hand or use some kind of script
generator like Rational Robot, both of which are tedious for regression
testing.

If you are not unit testing your code though then you will obviously not
get the benefit from this. We do this at the place where I work, so it is
not just a theory but I have seen real benefits. On of the first pieces of
code I had to work on all the logic in the GUI and it was virtually
impossible to automate the testing.

My 2 cents :-)

Mark
http://www.markdawson.org
--
http://www.markdawson.org
"Jeff S" wrote:
Okay, I just finally figured out the Model View Presenter pattern as
presented by Martin Fowler
(http://www.martinfowler.com/eaaDev/M...resenter.html). I even got a
small model of it working in a Windows Forms app I created from scratch.
Pretty cool how the form is sitting there and gets populated from the
Presenter - and the Form is pretty dumb (i.e., it really has no clue where
it's getting populated from.).

I understand that creating a "dumb" UI layer (per MVP and similar patterns)
has the benefit of allowing us to have multiple forms that all get populated
from the same Presenter. Great. What if I have no intention of ever doing
that (i.e., I have good reason to think I'll never have multiple screens
presenting the same model/data; or I'll likely never be providing both a Web
UI and Windows or Mobile UI). Should I still implement MVP or some other
means of separating the UI (Form) from the underlying data?

Please understand that I already know the answer is likely "yes, of course
you should separate it all out."

But what I would really appreciate are some specific benefits of doing such
separation and concrete examples if possible (reasons beyond the theoretical
"if you ever need to it will all be ready to go.").

Thanks for your time and consideration.

-Jeff

Feb 16 '06 #2
Hi Jeffs,

Generally this kind of stuff requires more work for the conception of the
control, but give it more flexibility or tweakability shall I say.
So if it is just for 1 end user screen, don't bother.
The only time I found usefull to have a "presenter" was for my custom
textview in C#. all text layout / drawing / etc... is handled in the
DocumenUI class. That way I could reuse the layout/etc code for a credit
control, a PrintDocument, etc...

For simple, no brainer or very unique (i.e. not likely to be reused) drawing
task, this is a tad overkill.....
--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
"Jeff S" <A@B.COM> wrote in message
news:uf******** ******@TK2MSFTN GP15.phx.gbl...
Okay, I just finally figured out the Model View Presenter pattern as
presented by Martin Fowler
(http://www.martinfowler.com/eaaDev/M...resenter.html). I even got a
small model of it working in a Windows Forms app I created from scratch.
Pretty cool how the form is sitting there and gets populated from the
Presenter - and the Form is pretty dumb (i.e., it really has no clue where
it's getting populated from.).

I understand that creating a "dumb" UI layer (per MVP and similar
patterns) has the benefit of allowing us to have multiple forms that all
get populated from the same Presenter. Great. What if I have no intention
of ever doing that (i.e., I have good reason to think I'll never have
multiple screens presenting the same model/data; or I'll likely never be
providing both a Web UI and Windows or Mobile UI). Should I still
implement MVP or some other means of separating the UI (Form) from the
underlying data?

Please understand that I already know the answer is likely "yes, of course
you should separate it all out."

But what I would really appreciate are some specific benefits of doing
such separation and concrete examples if possible (reasons beyond the
theoretical "if you ever need to it will all be ready to go.").

Thanks for your time and consideration.

-Jeff

Feb 16 '06 #3
"Jeff S" <A@B.COM> a écrit dans le message de news:
uf************* *@TK2MSFTNGP15. phx.gbl...

| Okay, I just finally figured out the Model View Presenter pattern as
| presented by Martin Fowler

This article doesn't really talk about the "proper" MVP pattern; it seems to
be a slightly more sophisticated MVC pattern.

I have written a complete MVP pattern for Delphi and you can see the
articles on my site : www.carterconsulting.org.uk

| I understand that creating a "dumb" UI layer (per MVP and similar
patterns)
| has the benefit of allowing us to have multiple forms that all get
populated
| from the same Presenter. Great. What if I have no intention of ever doing
| that (i.e., I have good reason to think I'll never have multiple screens
| presenting the same model/data; or I'll likely never be providing both a
Web
| UI and Windows or Mobile UI). Should I still implement MVP or some other
| means of separating the UI (Form) from the underlying data?

Whether you use MVC/P or any other pattern, it really does help your sanity
and the future maintainability of your code.

| Please understand that I already know the answer is likely "yes, of course
| you should separate it all out."

See, I told you so :-))

| But what I would really appreciate are some specific benefits of doing
such
| separation and concrete examples if possible (reasons beyond the
theoretical
| "if you ever need to it will all be ready to go.").

Let me know if my articles help.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Feb 16 '06 #4
Hi Jeff

You could also look at this from the other direction. By keeping the
presentation separate, it doesn't just allow you to add another viewer to
your data. It also allows you to reuse your presenter, since anything that
complies with the interface can be presented in the same way, so you can
have a generic viewer for all your data.

HTH

Charles
"Jeff S" <A@B.COM> wrote in message
news:uf******** ******@TK2MSFTN GP15.phx.gbl...
Okay, I just finally figured out the Model View Presenter pattern as
presented by Martin Fowler
(http://www.martinfowler.com/eaaDev/M...resenter.html). I even got a
small model of it working in a Windows Forms app I created from scratch.
Pretty cool how the form is sitting there and gets populated from the
Presenter - and the Form is pretty dumb (i.e., it really has no clue where
it's getting populated from.).

I understand that creating a "dumb" UI layer (per MVP and similar
patterns) has the benefit of allowing us to have multiple forms that all
get populated from the same Presenter. Great. What if I have no intention
of ever doing that (i.e., I have good reason to think I'll never have
multiple screens presenting the same model/data; or I'll likely never be
providing both a Web UI and Windows or Mobile UI). Should I still
implement MVP or some other means of separating the UI (Form) from the
underlying data?

Please understand that I already know the answer is likely "yes, of course
you should separate it all out."

But what I would really appreciate are some specific benefits of doing
such separation and concrete examples if possible (reasons beyond the
theoretical "if you ever need to it will all be ready to go.").

Thanks for your time and consideration.

-Jeff

Feb 16 '06 #5
I totally agree with Mark.

I would also add:

* It is easier to understand when maintaining it because the roles are
divided up better.
* I seem to remember a refactoring tool that made pulling interfaces out of
classes trivial but I can't remember where I saw it (not in VS2005 express)
"Mark R. Dawson" <Ma*********@di scussions.micro soft.com> wrote in message
news:D8******** *************** ***********@mic rosoft.com...
Hi Jeff,
no example here but the nice benefit of this pattern is that because your
UI is mainly dumb and the bulk of your code lives inside the controller
and
model it makes your code easier to unit test. Because the controllers are
just classes they can be unit tested just like any other class, the more
code you have in the GUI the more you have to test through the GUI which
is
difficult, you either have to do it by hand or use some kind of script
generator like Rational Robot, both of which are tedious for regression
testing.

If you are not unit testing your code though then you will obviously not
get the benefit from this. We do this at the place where I work, so it is
not just a theory but I have seen real benefits. On of the first pieces
of
code I had to work on all the logic in the GUI and it was virtually
impossible to automate the testing.

My 2 cents :-)

Mark
http://www.markdawson.org
--
http://www.markdawson.org
"Jeff S" wrote:
Okay, I just finally figured out the Model View Presenter pattern as
presented by Martin Fowler
(http://www.martinfowler.com/eaaDev/M...resenter.html). I even got
a
small model of it working in a Windows Forms app I created from scratch.
Pretty cool how the form is sitting there and gets populated from the
Presenter - and the Form is pretty dumb (i.e., it really has no clue
where
it's getting populated from.).

I understand that creating a "dumb" UI layer (per MVP and similar
patterns)
has the benefit of allowing us to have multiple forms that all get
populated
from the same Presenter. Great. What if I have no intention of ever doing
that (i.e., I have good reason to think I'll never have multiple screens
presenting the same model/data; or I'll likely never be providing both a
Web
UI and Windows or Mobile UI). Should I still implement MVP or some other
means of separating the UI (Form) from the underlying data?

Please understand that I already know the answer is likely "yes, of
course
you should separate it all out."

But what I would really appreciate are some specific benefits of doing
such
separation and concrete examples if possible (reasons beyond the
theoretical
"if you ever need to it will all be ready to go.").

Thanks for your time and consideration.

-Jeff

Feb 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3287
by: Steve | last post by:
If someone says RTFM, go here... http://www.hudzilla.org/php/index.php <quote> Please read the copyright notice and abide by it. Some day I hope to publish this thing, and that would be impossible if it were copied uncontrollably. </quote>
2
2561
by: Design Pattern Catalog | last post by:
Thank you for your interest in "Design Patterns: Elements of Reusable Object-Oriented Design", by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. This message answers several frequently asked questions. If you thought you were asking for the source code, you must have made a mistake. Please try again! The "pattern home page", with all this information and more, is at...
4
1788
by: Joakim Olesen | last post by:
Hi, I'm looking for a book/books about design patterns (factory patterns, singleton patterns etc). The book doesn't have to be aimed towards C# developers in particular, but the patterns should of course be useful in a ..Net/C# environment. I hope you can help me. Thanks in advance!
1
2370
by: Jay | last post by:
The GOF text is widely considered the definitive book on the topic. Design Patterns: Elements of Reusable Object-Oriented Softare, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides Note, all the examples are in C++ but you can get through them with a little work.
1
1873
by: Josh28 | last post by:
Hi We are a group of two chaps just out of undergrad, we created a software to automate the use of Design Patterns. We have put it up at Source Forge--http://dpatoolkit.sourceforge.net/ The software has been designed using the .NET framework and coded in C#. The patterns can be stored as plug-ins in XML, adding any number of attributes like Intent, Behavior and the like... Class
13
6549
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by Steven John Metsker Design Patterns by Erich Gamma Head First Design Patterns by Elisabeth Freeman
4
3470
by: myhotline | last post by:
Hi there, I was wondering from where i can get the source code of patterns implemented in either C# or Vb.NET. Any help or advice will be highly appreciated. Thanks in advance. Regards, -ANaive
12
1895
by: Jeff | last post by:
I'm just getting up to speed on OOP patterns (e.g, MVC) and I'm wondering how closely they are followed out in the real world. Do those of you who use them try to follow them as closely as possible and deviate only as necessary? Or do you only generally follow them; mix-n-match as necessary? Just wondering what I should be looking to accomplish with OOP patterns in general. Thanks!
7
3100
by: =?Utf-8?B?bWF2cmlja18xMDE=?= | last post by:
Hi, I would like to know more about design patterns and specifically using C#. Can any one recommend a good book? Thanks
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.