473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.UpdateThisT hing(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 2721
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******** ********@tk2msf tngp13.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.UpdateThisT hing(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 CustomerControl ler 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.UpdateThisT hing(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
2389
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 hierarchy of algebraic matrices with the addition operation. Thus, I want to have a virtual base class class Matr;
3
2124
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 peers were writing "better" C++ code. By "better" I mean that it more regularly looked like C++ (use of objects, streams, exceptions, and...
3
2215
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 ThunderMusic
17
4646
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 analysis and I'm led to believe (but can't yet quantitatively establish as fact) that the two basic culprits are a lot of calls to: 1.) if(...
13
1899
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 "information intended for foreign audiences, including public diplomacy and PSYOP, increasingly is consumed by our domestic audience and...
36
2459
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! -- B. Y.
3
1786
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 the outgoing responses (which are generated by the server). Operations have some common elements, and some which are distinct to the operation type...
6
3648
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 and bitwise operations are architecture dependant. The intention is to store two bytes, as chars, extracted from a short input parameter as: ...
4
2120
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 point operations. As it is a big project it is not possible to check every line manually, so is there any other method to detect floating point...
0
2163
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 DOUBLE ENDED QUEUE operations a) Use names as data to perform all operations like enqueue,dequeue,print,etc. b)Use students records as data to perform...
0
7697
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...
0
7612
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...
0
8120
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...
1
7672
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.