Re: A Proposal (why we should have setBold(true))


Subject: Re: A Proposal (why we should have setBold(true))
From: Mike Nordell (tamlin@algonet.se)
Date: Wed May 31 2000 - 03:05:25 CDT


I'd just like to insert a few comments about BPs otherwise great ideas &
suggestions.

Bruce Pearson wrote:
> The problems you are having with this is the fact that classes for the
> editing and viewing are not separate. The view class not only
represents a
> view of the document it also is responsible for editing the document.
This
> means we cannot easily edit a document without having a view.
>
> The correct way of doing this is to have a DOCUMENT -- VIEW --
CONTROLLER
> pattern.

The usual definition is MVC - Model View Controller, but I agree. I think
I also mentioned this a few weeks back.

> A document should store a list of views. When a document is modified it
then
> sends a message to the attached views telling the views that they need
to
> update the view of the current document.

This is the Observer pattern. The Document is the Observable, the Views
are the Observers. I'm however not sure that the Document should know
about views. I think a Notifier/Broker/Central should be known by the
Document, and the Views for this document then subscribes to
notifications for a specific Document from that Notifier/Broker/Central.

> The controller stores the current insertion point and also various
> information like selection start and end points. When this information
> changes (eg use presses left arrow) the controller does required
operations
> and then tells the view to update its view of the insertion point. i.e.
View
> is also a view of the controller.

Many frameworks of today tend to also give the View the responsibility of
a Controller. In not-so-complex cases this simplifies, but since AbiWord
is a rather complex piece of software I also think it should be changed.
I'm however not sure that a View should know about the Controller. I
rather think that the View should *only* know about the Document, and
then the Controller sends notifications to the view about cursor
movement, new selection and and so on.

In implementing a framework (that I'm still working on) I came to the
conclusion that the Controller should be the sole input-handler (mouse &
kbd) regarding movement & modifications within the document. I the think
that the Document should implement the "external" (C++ callable)
operations like insert, delete_char, delete_selection and so on. It would
be interesting to have some comments on this issue.

> Implementing this at this stage may or may not be a huge job and may
bring
> up a whole range of other implementation issues. Does any body have any
> comments. Is this something we need to do now or should other things be
done
> before hand.

I think it would be quite a measureable effort. :-)

The problem with letting this slip by at this time, is that it will
probably be exponentially (OK, I perhaps exaggerate a bit) more work
involved to get it working later on. I started on the cursor class to try
to sneak in some offloading of responsibilities for the View class, but a
redesign is IMHO in place. If it takes place I think the cursor movement
code should be moved into the Controller, and the Cursor class should
only take care of displaying/hiding the cursor/visible-IP.

/Mike - please don't CC



This archive was generated by hypermail 2b25 : Wed May 31 2000 - 02:01:55 CDT