473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 9466
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**************@TK2MSFTNGP15.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**************@TK2MSFTNGP15.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*********@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.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
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...
2
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...
4
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...
1
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 ...
1
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...
13
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...
4
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
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...
7
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.