473,395 Members | 1,791 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,395 software developers and data experts.

MVP and DAL Operations

I'm designing an implementation of the Model View Presenter (MVP) pattern
for a Windows Forms MDI application.

Question: From where would it generally make sense to *initiate* data access
(e.g, CRUD) operations - the Model or the Presenter?

Please note that I'm *not combining* the data access layer with the MVP
objects. Rather, I have a completely separate DAL. Even so, the DAL methods
must be called/initiated from somewhere within the MVP objects. My tendency
is to put DAL calls into the Model (e.g., DAL.UpdateThisThing(thingID)), but
doing that would seem to have the model doing much more than the MVP pattern
intends for it to be doing. So this leaves the Presenter as the apparently
reasonable place in which to place calls to the DAL.

Thoughts? Opinions? Perspective?

Thanks!
Feb 20 '06 #1
2 2708
I use the MVC pattern, but I thing it's the same thing...
I believe that the "C" (controller) or "P" (presenter) should process the
workflow of your application, making the navigation between your forms,
checking if some page can be open, etc...
But all persistence should be made by the model. The model is light,
anyway... The model should call another class to persist your data, a BLL or
something like that.
I made two MVC implementations, one in java and another in C# (ASP.NET). On
both, the model was responsable for data persistance. The BLL class was
configured in my "task" (when using Microsoft UIPAB), and other things were
also configured on this class.

You should have in mind that the model does not change - the presenter and
the view can change... The model is aware of what the view and the presenter
are, but the view and the presenter knows about the model (have references
to it). I use the model to persist data, and I also keep other things on the
model (even navigation values - I have a "free" hashtable to store this
stuff)...

In a phare, use the model...
"Jeff S" <A@B.COM> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl...
I'm designing an implementation of the Model View Presenter (MVP) pattern
for a Windows Forms MDI application.

Question: From where would it generally make sense to *initiate* data
access (e.g, CRUD) operations - the Model or the Presenter?

Please note that I'm *not combining* the data access layer with the MVP
objects. Rather, I have a completely separate DAL. Even so, the DAL
methods must be called/initiated from somewhere within the MVP objects. My
tendency is to put DAL calls into the Model (e.g.,
DAL.UpdateThisThing(thingID)), but doing that would seem to have the model
doing much more than the MVP pattern intends for it to be doing. So this
leaves the Presenter as the apparently reasonable place in which to place
calls to the DAL.

Thoughts? Opinions? Perspective?

Thanks!

Feb 20 '06 #2
I've seen implementations of the MVC/MVP pattern which are, in my humble
opinion, not exactly correct. The thing I often see is the following:
there is a presenter class (e.g. a windows form) and a model class (a
custom object). very often, people have the presenter class intantiated
first en it is the presenter class that keeps a reference to the model
class.

I think this is wrong. What i do is the following.

I make classes which I call controlers. They control the user interface.
Let me give an example: I want to show some information on a customer. I
will create an instance of a CustomerController class (the model class)
which will get the information about the customer from the DAL and
create a form to show all the information. It is the controller that
sets the date on the form and that handles the events.
The reason I do it this way is the following. My winforms are completely
independent from any other class! They have properties to set the data
en they fire event when the user clicks on a button or changes a field
etc. This makes the winform like a blackbox: i put some data in it, en
when the user does something, the form returns me something. This means
that I have for kinds of classes: forms or webpages, controllers,
business objects and DAL objects.

In most implementations of the mvc/mvp pattern i've seen, the
presentation layer components (forms/webpage...) are not completely
independent form the model classes, in my opinion, this is a shortcoming...

So, espacially for you, I would say, the access to the DAL is something
for the process classes. For you, it depends on what you understand as
the 'model', if it are your business objects: do not put any code to
access the DAL in there! If you model controls the flow of the program:
this is the place to be!

Hope this gives you some ideas.

Jeff S wrote:
I'm designing an implementation of the Model View Presenter (MVP) pattern
for a Windows Forms MDI application.

Question: From where would it generally make sense to *initiate* data access
(e.g, CRUD) operations - the Model or the Presenter?

Please note that I'm *not combining* the data access layer with the MVP
objects. Rather, I have a completely separate DAL. Even so, the DAL methods
must be called/initiated from somewhere within the MVP objects. My tendency
is to put DAL calls into the Model (e.g., DAL.UpdateThisThing(thingID)), but
doing that would seem to have the model doing much more than the MVP pattern
intends for it to be doing. So this leaves the Presenter as the apparently
reasonable place in which to place calls to the DAL.

Thoughts? Opinions? Perspective?

Thanks!

Feb 21 '06 #3

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

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
3
by: Scott Brady Drummonds | last post by:
Hello, all, My most recent assignment has me working on a medium- to large-sized Windows-based C++ software project. My background is entirely on UNIX systems, where it appears that most of my...
3
by: ThunderMusic | last post by:
Hi, I have 2 UInt64 to add and then divide the result by another value. How can I do this? because the math operators have not been defined for UInt64. Can somebody help please? Thanks ...
17
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
13
by: Immanuel Goldstein | last post by:
Obtained under the Freedom of Information Act by the National Security Archive at George Washington University and posted on the Web today, the 74-page "Information Operations Roadmap" admits that...
36
by: mrby | last post by:
Hi, Does anyone know of any link which describes the (relative) performance of all kinds of C operations? e.g: how fast is "add" comparing with "multiplication" on a typical machine. Thanks!...
3
by: Hallvard B Furuseth | last post by:
I'm wondering how to design this: An API to let a request/response LDAP server be configured so a user-defined Python module can handle and/or modify some or all incoming operations, and later...
6
by: carsonbj | last post by:
I have an issue where the below operation works on a little-endian architecture but not on a big-endian architecture. I was under the impression that pointer arithmetic is architecture independant...
4
by: alex | last post by:
hi friends ... i am facing a problem while detecting floating point operations in my project, please help me. i want to find out the places in my C/C++ project where i am doing floating...
0
by: tabassumpatil | last post by:
Please send the c code for: 1.STACK OPERATIONS : Transfer the names stored in stack s1 to stack s2 and print the contents of stack s2. 2.QUEUE OPERATIONS : Write a program to implement...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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.