Changes between Version 47 and Version 48 of mvc
- Timestamp:
- 02/19/24 17:13:54 (9 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
mvc
v47 v48 36 36 At the root is the MVC {{{Model}}} interface. A model basically is an object, which implicitly contains some values that can be adjusted. The interface only specifies that the object broadcasts Event objects whenever something changes in the model. 37 37 A Model is called a Compound Model if it contains sub-models. For instance a Person compound model may contain a StringModel containing the name, and a NumberModel containing the age. 38 39 40 === Model to Immutable Object 41 Usually the base objects are immutable, while the model that edits the objects is by definition mutable. 42 One approach would be to create an adapter that takes the base model and maps an adapter around it. But for more complex base objects, the adapter tends to become unreadable very quick. 43 44 Instead we recommend to make a XModel for every base object X. The XModel then contains a set of YModels for all Y that are in X. Also the XModel attaches listeners to these YModels so that it can notify its listeners about changes in submodels. This way, XModel can deliver the proper YModel for contained objects without extra adapter code. XModel can also contain a getX() that returns a base object X from the current settings in the XModel. 45 38 46 39 47 === Event object … … 144 152 145 153 146 147 == model and immutable object148 Usually the base objects are immutable, while the model that edits the objects is by definition mutable.149 One approach would be to create an adapter that takes the base model and maps an adapter around it. But for more complex base objects, the adapter tends to become unreadable very quick.150 151 Instead we recommend to make a XModel for every base object X. The XModel then contains a set of YModels for all Y that are in X. Also the XModel attaches listeners to these YModels so that it can notify its listeners about changes in submodels. This way, XModel can deliver the proper YModel for contained objects without extra adapter code. XModel can also contain a getX() that returns a base object X from the current settings in the XModel.