Skip to content

Examples

kwaxer edited this page Sep 29, 2017 · 3 revisions

Simple STRING (Model) ↔ EV_TEXT_FIELD (View)

Our desktop GUI has an EV_TEXT_FIELD and we want to hook it up to a corresponding STRING attribute on some class. The goals of the “controller(s)” are:

  1. Move {STRING} content ↔ {EV_TEXT_FIELD}.text
    1. When relationship between M ↔ V is created
    2. When M content changes and it is appropriate to update V
  2. Move {EV_TEXT_FIELD}.text{STRING}
    1. When V content changes
    2. Alternatively — when “Save” mechanism is triggered

Note. “Save” mechanism. Layers of persistence may be implemented in various ways. Some workflows will want Models to only receive their View content updates en masse based on some “Save” trigger. Otherwise, other workflows will want Models to be updated with View content as the user makes changes (i.e. key presses or mouse movements or clicks).

Conversion of DATE (Model) ↔ EV_TEXT_FIELD (View)

Various forms of Base Data Types may require conversion from the Model data type to a reasonable data type for presentation. This will be especially true for transmission of data to web-based front ends, where data must be converted to appropriate text representations and back again.

  1. {DATE} & {DATE_TIME} in the Model ↔ {STRING}s in the View
  2. {BOOLEAN} in the Model ↔ {STRING}, checkboxes, or radio buttons in the View
  3. {CHARACTER} in the Model ↔ {STRING}s in the View
  4. {REAL}, {INTEGER}, or {NATURAL} in the Model ↔ {STRING}s in the View

Consider various forms of base Eiffel data types and how they might be presented in some view. The view may not be a standard EV_PRIMITIVE control, but may include other forms including media (pictures, movies, and audio). For the moment, the MVC library ought to focus on the standard EV_PRIMITIVE controls as conversion targets for Model base data.

Clone this wiki locally