Re: MVC paradigm: multiple controllers?
Re: MVC paradigm: multiple controllers?
- Subject: Re: MVC paradigm: multiple controllers?
- From: Keith Blount <email@hidden>
- Date: Tue, 5 Oct 2004 12:51:17 -0700 (PDT)
Many thanks for your reply. The advice about not
having too many controllers but at the same time not
throwing everything into one controller seems sound,
though a little harder to work out than it sounds!
Notifications seem a good way to go, but I'm still a
little confused about how - or whether - to split up
controllers that deal with the same data. For
instance, like I say, I have a table view that shows
some of the same data as an outline view (much like in
Xcode) - should they both use the same controller? If
not, how can they both access the same data? Surely
the data class has to be instantiated in only one
place? But if they should use the same controller,
then it will get pretty long and unmanageable when all
the delegate methods for the outline view and the
table view are implemented along with all of the
saving and opening of documents etc.
Is there a good tutorial on controller management
anywhere? Most tutorials and examples in books deal
with simple programs that can happily use one
controller; I would really like to read something
about using and splitting up controllers effecively in
a large program.
Thanks again!
Keith
--- J Tichenor <email@hidden> wrote:
>
>
>
>
I too am new to cocoa and am learning as I go, and
>
will probably have
>
to go back and fix a million mistakes. You can and
>
should use as many
>
controllers as you need to, but no more. My
>
understanding is the two
>
mistakes people make are a) putting too much in one
>
controller and b)
>
creating too many controllers that don't do enough.
>
>
I am using NSNotifications to keep all my
>
controllers in sync and so
>
far it's worked out well. My general philosophy,
>
which may or may not
>
be right, is that each major view gets it's own
>
controller. I am not
>
using Bindings yet, and don't know whether one
>
should give every table
>
in one's interface it's own NSArrayController --
>
assume so, but again
>
I'm just learning...
>
>
FWIW --
>
>
J
>
>
>
> Hello,
>
>
>
> I would be very grateful for some general advice
>
on
>
> the model-view-controller paradigm as regards
>
multiple
>
> controllers.
>
>
>
> I am currently starting work on my first
>
> large(-ish)-scale Cocoa project. I have been
>
learning
>
> Cocoa over the past few months using books such as
>
> Kochan, Hillegass, Anguish et al, and have mostly
>
been
>
> working on small projects with this larger project
>
in
>
> mind. I have created nearly all of the (reusable)
>
view
>
> and model classes I need, and now I have to put it
>
all
>
> together.
>
>
>
> My question will probably seem very basic to Cocoa
>
> gurus, but here it is: how do you go about
>
organising
>
> controller classes for a large project? Until now,
>
all
>
> my projects have had one controller class to deal
>
with
>
> everything, which is simple enough. But when I did
>
a
>
> prototype of my project as a document-based app, I
>
> soon noticed that MyDocument was becoming
>
unwieldy, as
>
> it had to deal with file saving, moving the data
>
in
>
> and out of the outline and table views and various
>
tab
>
> views, handling various delegate methods, setting
>
up
>
> subviews, and so on. Do most projects only have
>
one
>
> controller, or do larger projects break down
>
> controllers into multiple classes? Seeing as the
>
> controller class has to move all the model data
>
around
>
> between views, I can't quite see how this can be
>
> split. For instance, in my head it would seem
>
ideal to
>
> have separate controllers for the outline view and
>
> table view, but seeing as the table view displays
>
> filtered data from the outline view, this seems
>
quite
>
> complicated.
>
>
>
> ...That last paragraph should give you some idea
>
of my
>
> confusion. Just some general advice on organising
>
> controller classes in large projects would be much
>
> appreciated, before I go and throw everything plus
>
the
>
> kitchen sink into MyDocument.
>
>
>
> Many thanks for any help,
>
> Keith
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden