Changes between Initial Version and Version 1 of CORE_MVC_BASE


Ignore:
Timestamp:
10/15/08 16:56:11 (17 years ago)
Author:
peko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CORE_MVC_BASE

    v1 v1  
     1= General Overview = 
     2These are the base classes that of which the MVC consists: [[BR]] 
     3MVC is based upon the MVC pattern.  
     4== Model == 
     5Model represents this part of the application that is responsible for the persistence and the things that are later displayed by the View. 
     6Our Model (a single instance of it) consists of: [[BR]] 
     7 * [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/app/App.java@112 App] 
     8 * the App has Books 
     9 * a [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/book/Book.java@112 Book] has Pages 
     10 * a [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/page/Page.java@112 Page] contains Frames 
     11 * [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/frame/Frame.java@112 Frame]s on the other hand a various by type and functionality: 
     12  * [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/frame/text/TextFrame.java@112 TextFrame]s 
     13  * [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/frame/image/ImageFrame.java@112 ImageFrame]s 
     14  * [source:/trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/model/frame/media/MediaFrame.java@112 MediaFrame]s 
     15 
     16Diagram: [[BR]] [[Image(source:/trunk/sophie2-platform/doc/uml-design-diagrams/SimpleModelHierarchy.png)]] 
     17 About the diagram: 
     18 * an App contains Books 
     19 * a Book contains Pages 
     20 * a Page contains Frames 
     21 * Frames are divided into three types which extend the functionalities of a Frame. The tree types are: !TextFrame, !ImageFrame and !MediaFrame. 
     22 
     23== View == 
     24The View in Sophie2.0 is the visual representation of what is in the Model. Every change in the Model affects the View and this is done '''automatically''' via the properties library. 
     25Our View contains: 
     26 * [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/app/AppView.java@203 AppView] 
     27 * The  [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/app/AppView.java@203 AppView] has !BookViews 
     28 * a [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/book/BookView.java@148 BookView] contains !PageViews 
     29 * a [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/page/PageView.java@112 PageView] has various [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/frame/FrameView.java@112 FrameView]s corresponding to the Frames in the model: [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/frame/TextFrameView.java@112 TextFrameView], [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/frame/ImageFrameView.java@112 ImageFrameView], [source:trunk/sophie2-platform/modules/org.sophie2.messy/src/main/java/org/sophie2/messy/view/frame/MediaFrameView.java@112 MediaFrameView] 
     30Diagram of the View part of the MVC is not needed since every View is a corresponding part of the model. A diagram for the Views will be more or less like the diagram of the model. For example every !FrameView is a visual representation of a Frame. A Book has a corresponding !BookView etc. [[BR]] 
     31 
     32== Controller == 
     33 
     34The Controller part is represented by the Logics. We have !AppLogic, !BookLogic, !PageLogic and !FrameLogic. At this point we have only a !TextFrameLogic instead of three !FrameLogics(for Text, Image and Media) but three Logics will be provided later. While one can create instances of the model and view (Books, Pages, Frames, !AppViews, !BookViews, !PageViews etc.), the Logics are singletons which means that they have only one instance which is used to control the instances of the model. The only instance of a Logic is the one invoked by the View. This means that if we have multiple BookViews, we use only one BookLogic to apply changes to the Books. Logics are entirely and only used to control the model and change it. They '''do not have state'''. By convention, the names of the methods which control the Model should start with "user" and continue with an explanation of what the method changes or does. Example: (method which is part of the !PageLogic and serves to create a Frame on a certain point on the screen)[[BR]] 
     35{{{ 
     36public void userDropFrame(PageView pageView, ImmPoint location, final FrameKind kind) { 
     37                if (!pageView.isInReaderMode()) { 
     38                        insertFrame(pageView, new ImmRect(location, FrameStyle.DEFAULT_FRAME_SIZE), kind); 
     39                } 
     40        } 
     41}}} 
     42 
     43Since the Logics are the part of Sophie where the control takes place below is provided a detailed digram of the Logics which contains the methods used to apply changes. 
     44 
     45Diagram: [source:/trunk/sophie2-platform/doc/uml-design-diagrams/Logics.png Logics Heirarchy] 
     46 
     47== MVC == 
     48The Model-Viewer-Controlled in Sophie2.0 can be noticed in four levels (or layers) and these are: App, Book, Page and Frame including the three types of frames. Here is a detailed diagram of the MVC. One can think of it as a grid containing layers of MVCs. [[BR]] 
     49 
     50[[Image(source:/trunk/sophie2-platform/doc/uml-design-diagrams/MVC-diagram-detailed.png)]]. [[BR]] 
     51 
     52Although changes are supposed to happen on one layer only (as described in the diagram), sometimes a user interaction may appear in the App which may result in invoking a !FrameLogic. This is a typical scenario if a new frame is created. 
     53 
     54Next is a general picture of the MVC on one level only. It is important to notice that: 
     55 * the View is controlled by the user. The corresponding user method is invoked in the Logic and the model is changed. 
     56 * Every change in the model affects the corresponding View. (this is done automatically by the pro lib). 
     57 * the whole flow of information goes in one way ONLY. 
     58 
     59[[Image(source:/trunk/sophie2-platform/doc/uml-design-diagrams/MVC-diagram.png)]]  
     60 
     61= General Rules = 
     62 * View is '''automatically''' updated. 
     63 * Model is modified '''only''' by the Logic. If model is to be changed you '''should''': 
     64  * Use the '''implemented''' methods int he corresponding Logic to do this. 
     65  * Create methods to serve your needs if '''there aren't''' such. These methods: 
     66   * should be '''public methods''' that are invoked by the View and '''should''' 
     67    * begin with user.... 
     68    * be public.... 
     69   * may use '''helper''' methods to provide the functionality needed. The helper methods '''should not''': 
     70     * be public. 
     71     * begin with '''user'''. 
     72