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