Skip navigation.
 
mlRe: MVC view/controller separation question
FROM : Johnny Deadman
DATE : Mon Apr 04 15:14:55 2005

The approach I would take would be to have the note objects know how 
to draw themselves, and have a note manager which manages the notes 
and tells them when and where to draw, either in or around the textview.

I have something very similar in my app. In this case the structure 
is as follows

GLPageLayoutView -- responsible for drawing and maintaining the 
multiple page view of the doc. Only responsible for visuals.
GLTextView -- subclass of NSTextView which manages (only the most) 
basic user input and display of text.
GLPageLayoutManager -- responsible for co-ordinating the system of 
Layout Managers, TextViews and Text Containers, and telling the 
pageLayoutView when and what to draw.
GLInputManager -- delegate for NSTextView which handles sophisticated 
user input via delegations and notifications
GLNote -- a note which knows how to draw itself in a view
GLDraft -- a draft of the document which knows all about its 
GLNotes... this is the document model, as opposed to the NSDocument. 
It is a 'dumb' data object. The NSDocument is its controller.

In this case the pageLayoutManager pulls in the notes, which are 
'owned' by the document model... the hierarchy looks like this

The GLNote and GLDraft are models, the things with 'view' in the 
title are views, and the Manager is the  controller.

NSTextView is a little confusing because it feels like a controller 
in the way it manages user input. However it is important to treat it 
as a view and not pile responsibilities on it by subclassing. It is 
better to put the responsibilities either in an NSWindowController or 
a separate controller... or even several... in my case I created an 
InputManager which is used to alter the TextView's behavior using 
delegation.

IMO using coredata & bindings really helps be more rigorous about all 
this since almost all the code you are writing becomes controller 
code, so that almost every object you create explicitly is a controller.




On 4-Apr-05, at 6:25 AM, Keith Blount wrote:

> My question is simply one of good design: should the
> text view be responsible for keeping track of this
> array, as it is currently, or should I set up a
> NotesController class to handle this that is
> instantiated by the text view, and have my text view
> call methods on that?

Related mailsAuthorDate
mlMVC view/controller separation question Keith Blount Apr 4, 12:25
mlRe: MVC view/controller separation question Johnny Deadman Apr 4, 15:14
mlRE: MVC view/controller separation question Keith Blount Apr 4, 16:39
mlRe: MVC view/controller separation question Serge Meynard Apr 4, 16:58
mlRe: MVC view/controller separation question Keith Blount Apr 4, 18:33
mlRe: MVC view/controller separation question John Brownlow Apr 4, 22:28
mlRe: MVC view/controller separation question Keith Blount Apr 4, 23:18