Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (233.16 KB, 6 trang )
<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
<b>2</b>
z
<b>The </b><i><b>model</b></i><b>represents some </b>
<b>information about the </b>
<b>domain. </b>
<b>The</b><i><b>view</b></i><b>represents the </b>
<b>display of the model in the </b>
<b>UI. </b>
<b>The</b><i><b>controller</b></i><b>takes user </b>
<b>input, manipulates the </b>
<b>model, and causes the view </b>
a
b
c
a b c
a = 50%
b = 30%
c = 20%
<b>change notification</b>
<b>requests, modifications</b>
x
y
z
a b c
<b>3</b>
z
<b>Fundamentally presentation and model are about </b>
<b>different concerns.</b>
<b>Depending on context, users want toseethe same basic </b>
<b>model information in differentways.</b>
<b>Non-visual objects are usually easier to testthan visual </b>
<b>ones.</b>
<b>Thepresentation dependson themodel</b>
<b>Observerpattern [GOF]</b>
Model
Presentation
z
<b>Support editable and non-editable behavior: one view + </b>
<b>two controllers</b>
<b>Controller = Strategiespattern [GOF]</b>
<b>Useful for Web interface</b>
<b>5</b>
z
<b>Separating the presentation from the model</b>
<b>Separating the controller from the view (less important)</b>
z
<b>6</b>
<b>7</b>
<b>namespace XXX</b>
<b>{</b>
<b>class Form1 : Form</b>
<b>{</b>
<b>private model m;</b>
<b>public Form1(model m)</b>
<b>{</b>
<b>this.m = m;</b>
<b>…</b>
<b>}</b>
<b>private void B1_Click(object …)</b>
<b>{</b>
<b>m.press(1);</b>
<b>xxx.Text = m.GetResult().ToString();</b>
<b>}</b>
<b>}</b>
model
form
<b>9</b>
<b>namespace XXX</b>
<b>{</b>
<b>class Form1 : Form</b>
<b>{</b>
<b>private model m = new model;</b>
<b>public Form1()</b>
<b>{</b>
<b>}</b>
<b>private void B1_Click(object …)</b>
<b>{</b>
<b>m.press(1);</b>
<b>xxx.Text = m.GetResult().ToString();</b>
<b>}</b>
<b>…</b>
<b>}</b>
<b>}</b>
model
form
<b>10</b>
List<Word>
<b>SpellerForm</b>
-words
<b>Dictionary</b>
-English
-Chinese
<b>Word</b>
View & Control Model
-Question
-Solution
<b>11</b>
<b>SpellerForm</b>
-words
<b>Dictionary</b>
-English
-Chinese
<b>Word</b>
+Start()
<b>Speller</b>
Model Facade
View & Control
-Question
-Answer