Analysis
Overview
This group of tasks is about redesigning the book model of Sophie2 in accordance with the new model of resources. Since the model of the resources will be entirely different, the book model will change significantly as well. Currently it consists of the book, its pages and the page elements (frames, groups and book extras such as audio annotations and stickies). After the redesign, the model will be changed, with a better defined hierarchy of its elements, reflecting the new resources design as well. After this iteration, a complete design with a basic prototypical code as well as a schedule for the next weeks will be present.
Task requirements
- Analyze the current state of the book model:
- What classes are present and how are they related?
- What properties do the different elements have and are they all needed?
- Provide a new hierarchy of classes that better reflects their relationship.
- Provide a new design for the contents of the classes.
- Provide a prototypcal skeletons of the classes.
- Provide a schedule for the next iterations of this task:
- Estimate how much time is needed for the complete refactoring.
- Split the redesign into meaningful subtasks that can be completed in one week.
Keep in mind that this is closely related to the redesign of the resource model and should be done in parallel or after it. The change of the model will lead to refactoring the view and the logic. Take that into consideration when composing the schedule.
Task result
- Design diagrams of the new classes.
- Prototypical code of the new clases (with tests included).
- Schedule for the next actions to be taken.
Implementation idea
Consider the design drafts created by milo:
- All resources contain only immutable values.
- Consider having a class Element that is a superclass for pages, frames, groups and stickies.
- Consider creating a new module/package for the new model so that old things are not broken.
Related
The design drafts
GROUP_RESOURCE_MODEL_REDESIGN_R0
How to demo
Show the design diagrams and the prototype classes.
Design
The existing book model has been analyzed and the following issues have been found:
- Redundancy and obsolete things (e.g., we do not need currentPage property - a book can be opened by two users simultaneously and they might be on different pages).
- Complex and unclear hierachy (e.g., groups are ResourcePageElements that implement an ElementContainer interface - we do not need that).
- Helpers that should not be in the model (e.g., methods for adding frames in the Page class).
Also, the model does not conform to the new resources design and will be thoroughly refactored. After that, the model will consist only of public static final fields, holding keys of immutable type. These keys will replace the properties we had in the old model. Helper methods will be separated in other classes. This will immensely simplify the model. Adding a new field to the model will be easy - just have to add a new key. Here is a class diagram of the new model:
The diagram does not show the subkeys of the CompositeKeys (for example the background and the border of the page and frame).
Another important things about the keys is that they should not have a null default value. Instead, they should use a default constant or a ResourceRef with a null location (for example "null://").
The skeletons of the classes are committed to mira's branch
Since the new model only consists of public static final fields, no tests are provided. Tests will be provided with the GROUP_RESOURCE_MODEL_REDESIGN_R0.
Here is a rough plan about the next steps of the refactoring:
- Finsih the resources model, clean up any issues on the book model - half a week.
- Replace the existing model with the new one, write helpers and update views and logics - 1 week.
- Find and fix issues, do finsihing touches - 1 week.
Implementation
The class hierarchy has been implemented according to the design. Every class temporarily has an R4 suffix that will be removed when replacing the old model. The changesets are: [4323] [4379] [4407] [4409] [4437] [4438] [4579]
There are tests for the static methods of the ResourceR4 class: [4478].
There will be helper classes that will serve as a bridge between the new and the old model. They will consist of getter methods that will access the keys. Here's an example:
public class BookHelper { private ResourceAccess access; public BookHelper(ResourceAccess access) { this.access = access; } public String getTitle() { return this.access.getRaw(BookR4.KEY_TITLE); } public ImmSize getPageSize() { return this.access.getRaw(BookR4.KEY_PAGE_SIZE); } }
These helpers will not have any setter methods. Instead, AutoActions will be written by programmers where they need to change the model. Helpers like addPage and others will be written as static methods in the views or in separate classes. They will take a ResourceModelChanger only and use it to perform the changes. This is only an idea of how they will look like and it might be changed. Writing these helpers will be part of the task for replacing the model (see below).
Here are the tickets of the other redesign tasks that are tightly connected with this one:
1782 (GROUP_RESOURCE_MODEL_REDESIGN_R0) - mira, meddle, and kyli are working on it.
1786 (HOT_TEXT_REDESIGN_R0) - vlado is working on it.
1788 (GROUP_GUI_REDESIGN_R0) - peko, tanya are working on it.
1789 (TIMELINES_REDESIGN_R0) - sveto is working on it.
All this should be with status de_ok before we start the refactoring.
Here are the tickets for the tasks that follow this one and will be finished in the next weeks:
1805 (GROUP_BOOK_MODEL_REDESIGN_R1) - At this iteration, actual replacement of the model should be done. This include writing helpers, syncing with other redesign tasks, etc. It should be finished in one week.
1806 (GROUP_BOOK_MODEL_REDESIGN_R2) - This iteration involves refining and cleaning up bugs related to the model refactoring. It might also include updating the logics and views. It should be finished in one week.
1807 (GROUP_SERVER_MODEL_REDESIGN_R0) - This tasks involves syncing the server with the new model. It also should provide server-client connectivity with the new model.
These tasks are of critical priority since they need to be finished before Beta 1 (2009-08-14).
Testing
Place the testing results here.
Comments
Write comments for this or later revisions here.
Attachments
- BookModelClassDiagram.jpg (210.6 KB) - added by boyan 16 years ago.