Re: Question on Cocoa concepts
Re: Question on Cocoa concepts
- Subject: Re: Question on Cocoa concepts
- From: Don Rainwater <email@hidden>
- Date: Fri, 9 Aug 2002 11:23:14 -0400
In the books, you've probably seen reference to the
Model-View-Controller design pattern, or MVC. Using MVC, you
compartmentalize your project so that the classes that represent the
data (Model) are separate from the classes that handle the user
interface (View). Classes in the Controller are used to move the data
between the Model and the View.
One of the benefits of separating the Model from the View is code
reuse. In theory, you could reuse the Model in another program that
interacts with the same data, even though the user interface (View) may
be different. For example, you may have different categories of users
who must use the same inventory data, but may have different levels of
access (read-only vs. read/write, or summary vs. detail). The Model
would be the same for both programs, but the Views would be different.
Later, you may add a third program that runs in the background to do
bulk updates or purge outdated records. That program could also use the
same Model, but may have no View at all.
As you've noticed, things get a little murky when you start talking
about the Controller. The examples in the books may seem too simple to
require the distinct separation of the three. It may be "superfluous"
for those, but being comfortable with MVC on simple projects will make
it easier to apply that design pattern to complex projects later.
I hope this is helpful.
On Friday, August 9, 2002, at 10:18 AM, Lorenzo Thurman wrote:
I have a couple of books on Cocoa programming, but there seems to be
something missing from them that I might need spelled out explicitly.
Looking through the examples they present, I see some use a controller
that manages the apps outlet/action behavior while others go without a
controller and simply wire interface components directly together. It
would seem, leaving out issues of complexity, that if components don't
have the desired behavior, then a controller is used and the action
behavior is defined there. If the components already have the necessary
behavior, then wiring them directly together is OK. Does this make
sense? If so, then I've also seen some examples where the use of a
controller is superfluous, which is the source of my confusion since
none of the books explicitly state "I'm using a controller because..."
or "A controller is not needed here because...". Maybe this is more
intuitive to many of you, but I need to get a better understanding of
it all before!
I embark on something complex.
Thanks
--
Don Rainwater, Technology Manager email@hidden
UCit Educational Services
University of Cincinnati
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.