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

Question on MVC in .NET

Hi,

We are developing an windows application and decided to use the MVC
design pattern. We decided to use windows application due to varuous
business processes which cannot be implemented in web very easily

Now my problem is very specific.

We have a main screen which shows some data called Main view. We have a
controller calss which holds a reference to the object of Main view and
underlying service. Now we want to save the details entered on the
screen to database, but before adding to database, we show a screen and
allows user to select to save on exiting one or new one and lot of
other stuff.

My questions are
1 - do we required to have a sepearate controller for each view. In our
case, MainController and SaveController or we should have only one
controller i.r. MainController.
2 - If only one controller is used and if that controoler is holding
object reference of Main view, how other view can be handled.
3 - If 2 contoller is used then how to pass the data from Main view to
Save view.

At the moment our project become so complex as v hv to pass the
MainController evertime between view and each view hv has its own
controller.

Any suggestion is appriciated

Jan 17 '07 #1
5 1360
Hello -pb-,

-We have a main screen which shows some data called Main view. We have
-a controller calss which holds a reference to the object of Main view
-and underlying service. Now we want to save the details entered on
-the screen to database, but before adding to database, we show a
-screen and allows user to select to save on exiting one or new one
-and lot of other stuff.
->
-My questions are
-1 - do we required to have a sepearate controller for each view. In
-our
-case, MainController and SaveController or we should have only one
-controller i.r. MainController.

Generally only one controller, but differen views.
Controller handles events from the different views

-2 - If only one controller is used and if that controoler is holding
-object reference of Main view, how other view can be handled.

Controller creates view, so it knows about views and handles its events

-3 - If 2 contoller is used then how to pass the data from Main view
-to Save view.

Noway. Each controller is separates for each view, no way to interact between
them.

-At the moment our project become so complex as v hv to pass the
-MainController evertime between view and each view hv has its own
-controller.

Several solutions to avoid this
- One controller which handles all views (you can use partial classes to
simplify handling the views)
- Combine the View and the Controller. MVC pattern allows this

I recommend you to read article (which I and my mate wrote) about MVC and
MVP patterns:
http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!650.entry

I hope it helps you to find your answers and make MVC more clear for you
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Jan 18 '07 #2
Hi,

Thanks for the informaiton.

After looking into your artical, we are actually using MVP more then
MVC (passive or active). Now as per your suggestion to have one
presenter for all different view, we have an interface which represents
each view and if we use only one presenter then all those interface
needs to be implemented by that one presenter which I think will make
thigns worse as now presenter has more then 1 view to handler.

Furthermore, we nned to comunicate between diferent view i.e. we need
to have Save view and Main view and on click of Save button on Save
view it need to save data from main view. Is there any other design
pattern to handle this or is something wrog we are doing may be wrong
design.

Let me know if u need anymore info. I will try to post the code as
well.

Michael Nemtsev wrote:
Hello -pb-,

-We have a main screen which shows some data called Main view. We have
-a controller calss which holds a reference to the object of Main view
-and underlying service. Now we want to save the details entered on
-the screen to database, but before adding to database, we show a
-screen and allows user to select to save on exiting one or new one
-and lot of other stuff.
->
-My questions are
-1 - do we required to have a sepearate controller for each view. In
-our
-case, MainController and SaveController or we should have only one
-controller i.r. MainController.

Generally only one controller, but differen views.
Controller handles events from the different views

-2 - If only one controller is used and if that controoler is holding
-object reference of Main view, how other view can be handled.

Controller creates view, so it knows about views and handles its events

-3 - If 2 contoller is used then how to pass the data from Main view
-to Save view.

Noway. Each controller is separates for each view, no way to interact between
them.

-At the moment our project become so complex as v hv to pass the
-MainController evertime between view and each view hv has its own
-controller.

Several solutions to avoid this
- One controller which handles all views (you can use partial classes to
simplify handling the views)
- Combine the View and the Controller. MVC pattern allows this

I recommend you to read article (which I and my mate wrote) about MVC and
MVP patterns:
http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!650.entry

I hope it helps you to find your answers and make MVC more clear for you
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Jan 22 '07 #3
Sorry there is some error in my previous reply. I am rectifying it and
rewrting it as follows

0 - We have one business component called BusinessProcess
1 - We have 2 interface IMainView and ISaveVIew
2 - IMainVIew is implemented by frmMainView form
3 - ISaveView is implemented by frmSaveView form
4 - We have one public class called MainPresenter and SavePresenter.
Both of them uses the BusinessProcess compoent to get/save data.
5 - MainPresenter holds the reference to the object of IMainView and
SavePresenter holds the reference to the object of ISaveVIew
6 - Form MainForm shows the data using MainPresenter and form SaveForm
shows the data using SavePresenter
7 - Now when user clicks on Save button the form, it created an object
of the form which implements the ISaveView and shows the form.
8 - Various data is shown on the form frmSaveView using SavePresenter
and BusinessProcess component
9 - On click on OK button on frmSave we want to save the data from
frmMainView.

Now in above context, can yu pls explain a bit more usage of abt
partial class and where it should fit together. At the moment what we
are doing is MainPresenter is passed to frmSave. frmSave uses its
SavePresenter to do various operation and on click it uses the
MainPresenter to calla function Save which then calls the
BusinessPrcess component's function Save.

In my opnion its not so good solution but is there any way out? Is
there any possible design error?

-pb- wrote:
Hi,

Thanks for the informaiton.

After looking into your artical, we are actually using MVP more then
MVC (passive or active). Now as per your suggestion to have one
presenter for all different view, we have an interface which represents
each view and if we use only one presenter then all those interface
needs to be implemented by that one presenter which I think will make
thigns worse as now presenter has more then 1 view to handler.

Furthermore, we nned to comunicate between diferent view i.e. we need
to have Save view and Main view and on click of Save button on Save
view it need to save data from main view. Is there any other design
pattern to handle this or is something wrog we are doing may be wrong
design.

Let me know if u need anymore info. I will try to post the code as
well.

Michael Nemtsev wrote:
Hello -pb-,

-We have a main screen which shows some data called Main view. We have
-a controller calss which holds a reference to the object of Main view
-and underlying service. Now we want to save the details entered on
-the screen to database, but before adding to database, we show a
-screen and allows user to select to save on exiting one or new one
-and lot of other stuff.
->
-My questions are
-1 - do we required to have a sepearate controller for each view. In
-our
-case, MainController and SaveController or we should have only one
-controller i.r. MainController.

Generally only one controller, but differen views.
Controller handles events from the different views

-2 - If only one controller is used and if that controoler is holding
-object reference of Main view, how other view can be handled.

Controller creates view, so it knows about views and handles its events

-3 - If 2 contoller is used then how to pass the data from Main view
-to Save view.

Noway. Each controller is separates for each view, no way to interact between
them.

-At the moment our project become so complex as v hv to pass the
-MainController evertime between view and each view hv has its own
-controller.

Several solutions to avoid this
- One controller which handles all views (you can use partial classes to
simplify handling the views)
- Combine the View and the Controller. MVC pattern allows this

I recommend you to read article (which I and my mate wrote) about MVC and
MVP patterns:
http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!650.entry

I hope it helps you to find your answers and make MVC more clear for you
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Jan 22 '07 #4
Hello -pb-,

Alex, the main author that article will reply u dimistifying you misunderstandings

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

-Sorry there is some error in my previous reply. I am rectifying it
-and rewrting it as follows
->
-0 - We have one business component called BusinessProcess
-1 - We have 2 interface IMainView and ISaveVIew
-2 - IMainVIew is implemented by frmMainView form
-3 - ISaveView is implemented by frmSaveView form
-4 - We have one public class called MainPresenter and SavePresenter.
-Both of them uses the BusinessProcess compoent to get/save data.
-5 - MainPresenter holds the reference to the object of IMainView and
-SavePresenter holds the reference to the object of ISaveVIew
-6 - Form MainForm shows the data using MainPresenter and form
-SaveForm
-shows the data using SavePresenter
-7 - Now when user clicks on Save button the form, it created an
-object
-of the form which implements the ISaveView and shows the form.
-8 - Various data is shown on the form frmSaveView using SavePresenter
-and BusinessProcess component
-9 - On click on OK button on frmSave we want to save the data from
-frmMainView.
-Now in above context, can yu pls explain a bit more usage of abt
-partial class and where it should fit together. At the moment what we
-are doing is MainPresenter is passed to frmSave. frmSave uses its
-SavePresenter to do various operation and on click it uses the
-MainPresenter to calla function Save which then calls the
-BusinessPrcess component's function Save.
->
-In my opnion its not so good solution but is there any way out? Is
-there any possible design error?
->
--pb- wrote:
->
>Hi,

Thanks for the informaiton.

After looking into your artical, we are actually using MVP more then
MVC (passive or active). Now as per your suggestion to have one
presenter for all different view, we have an interface which
represents each view and if we use only one presenter then all those
interface needs to be implemented by that one presenter which I think
will make thigns worse as now presenter has more then 1 view to
handler.

Furthermore, we nned to comunicate between diferent view i.e. we need
to have Save view and Main view and on click of Save button on Save
view it need to save data from main view. Is there any other design
pattern to handle this or is something wrog we are doing may be wrong
design.

Let me know if u need anymore info. I will try to post the code as
well.

Michael Nemtsev wrote:
>>Hello -pb-,

-We have a main screen which shows some data called Main view. We
have
-a controller calss which holds a reference to the object of Main
view
-and underlying service. Now we want to save the details entered
on
-the screen to database, but before adding to database, we show a
-screen and allows user to select to save on exiting one or new
one
-and lot of other stuff.
->
-My questions are
-1 - do we required to have a sepearate controller for each view.
In
-our
-case, MainController and SaveController or we should have only
one
-controller i.r. MainController.
Generally only one controller, but differen views. Controller
handles events from the different views

-2 - If only one controller is used and if that controoler is
holding -object reference of Main view, how other view can be
handled.

Controller creates view, so it knows about views and handles its
events

-3 - If 2 contoller is used then how to pass the data from Main
view -to Save view.

Noway. Each controller is separates for each view, no way to
interact between them.

-At the moment our project become so complex as v hv to pass the
-MainController evertime between view and each view hv has its own
-controller.

Several solutions to avoid this
- One controller which handles all views (you can use partial
classes to
simplify handling the views)
- Combine the View and the Controller. MVC pattern allows this
I recommend you to read article (which I and my mate wrote) about
MVC and MVP patterns:
http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!650.entry

I hope it helps you to find your answers and make MVC more clear for
you

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo

Jan 23 '07 #5

Use another schema:

0 - You have the business component called BusinessProcess and THIS
component IS model and used for interaction between Presenter(s) and
your Views.
....
6 - Form MainForm shows the data (interacting with BusinessProcess as
model) using MainPresenter and form SaveForm shows the data using
SavePresenter (we have only single one model - BusinessProcess and
all your business components)

So, when you click "Save" on the Main form:
7 - the form raises the event in MainPresenter and MainPresenter
stores the MainForm's data into the model
8p1 - MainPresenter asks SavePresenter to create the SaveForm.
8p2 - SavePresenter fills SaveForm with data from the model (data was
stored on the step 7), and shows the SaveForm
9 - On click the OK button on frmSave we raise the event in
SavePresenter which handle form data.
There are 2 cases:
a) You save all your data in the model and mark them "temporary".
When u need to save them your SavePresenter change the status of your
data.
b) You send data from the MainPresenter to model and then use this data
to show SaveForm. Then Again send SaveForm data to model to perform
real saving

Kind regards,
Alex Meleta [http://ameleta.spaces.msn.com]

Jan 23 '07 #6

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

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.