[Arp] Maintainig object state
Christophe Herreman
christophe_herreman at hotmail.com
Fri Apr 22 02:28:45 PDT 2005
Hi all,
We're currently developing some e-learning apps. They are all fed by XML
(using the XMLService which works fine, so far). They are then parsed to
objects of the type Course, Chapter, Assessment, AssessmentItem. Courses
contain Chapters, Chapters contain Assessment, etc.
The thing is that this XML data only needs to be loaded once in the
application (in reality not once, but just for this example). This is
important because we want to keep scores in the AsessmentItem objects for
instance. We also want to know what Chapters have been looked at by the
user.
The question is: Where do we save e.g. the Course object?
We made a subclass of ArpForm, IdiomaticForm which has a getModel and
setModel method. This seems like a good approach because when the app
starts, the Application form (extends IdiomaticForm and which is actually
the view of the Course model) broadcasts a getCourse event. The controller
maps it to a GetCourseCommand. That command calls the getCourse method on
the XMLService. The course gets loaded and parsed. When it is parsed, we
call viewRef.setModel(resultEvent.result). So the Application receives the
course object. Is this a good thing to do?
Another problem we have is that when we enter a Chapter, we want the
ChapterForm to get the chapter data. This shouldn't be loaded, because it is
already in the course model of the application. But how do we access it from
within the ChapterForm? Do we send an event (type:"getChapter", chapterID:3)
which Application listens for and then does something like:
function getChapter(eventObj){
chapterForm.showChapter(getModel().getChapterAt(chapterID));
}
I don't know if this is a good thing because Application now knows about the
showChapter method of ChapterForm.
Maybe a better way is to send that event to the controller. The controller
executes a getChapter command. That command reads the applications model
(how does he access it? viewRef._parent?) and the does
viewRef.setModel(chapter).
All the apps are offline CD-ROM apps.
Any advice, tips or tricks?
thx a million,
Christophe
More information about the Arp
mailing list