File tree Expand file tree Collapse file tree
HeadFirstDesignPatterns/src/mvc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33public class Go {
44 public static void main (String [] args ) {
55 NumberModelInterface model = new NumberModel ();
6- NumberControllerInterface controller = new NumberController (model );
6+ new NumberController (model );
77 }
88}
Original file line number Diff line number Diff line change 22
33public class NumberController implements NumberControllerInterface {
44
5- private SimpleNumberView view ;
65 private NumberModelInterface model ;
76 public NumberController (NumberModelInterface model ) {
87 this .model = model ;
98 model .init ();
10- view = new SimpleNumberView (model , this );
9+ new SimpleNumberView (model , this );
1110 }
1211 @ Override
1312 public void increase () {
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ public void createView(){
4848 bpmOutputLabel = new JLabel ("offline" , SwingConstants .CENTER );
4949 beatBar = new BeatBar ();
5050 beatBar .setValue (0 );
51- JPanel bpmPanel = new JPanel (new GridLayout (2 ,1 ));
5251 }
5352
5453 @ Override
Original file line number Diff line number Diff line change @@ -122,4 +122,14 @@ MVC模式,簡單的說就是把資料的實際操作包裝到Model中,把控
1221225.View向Model詢問,然後呈現變更後結果的View。
123123大致是這樣(隨著情況可以方便變更)
124124____
125-
125+ ##反模式
126+ ____
127+ 告訴你如何採用一個不好的解決方案解決一個問題。
128+ 就像是我之前寫的東西又爛擴充性又差,後來我改過自新了,我把之前的爛code寫成文件,說明這邊為什麼不好,為什麼有問題,來告知自己以及其他人不要犯同樣的錯誤這樣。
129+ ____
130+ ##心得
131+ ____
132+ 模式不一定要用,但要懂得概念,在適合的情境下去使用,有時硬是去使用模式,只會徒增複雜度,
133+ 一開始設計時不用刻意去想說要用什麼模式,而是一邊寫一邊發現適合可以用哪種模式時再加入模式。
134+ 兩種情況適合模式的存在,一個是問題需要解決,一個是確信未來的需求改變需要用此模式。
135+ ____
You can’t perform that action at this time.
0 commit comments