tailieunhanh - Programming Java 2 Micro Edition on Symbian OS A developer’s guide to MIDP 2.0 phần 8

Các mẫu thiết kế Model-View (MV) là một phiên bản đơn giản của mô hình MVC. Các mô hình MV là một biến thể cụ thể của các mô hình Observer (còn được gọi là thuê bao-Nhà xuất bản). Trong mô hình MV, lớp học Xem kết hợp các chức năng của View và các lớp điều khiển trong mô hình MVC. | 322 MAKING JAVA CODE PORTABLE view View controller Controller model Model 1 1 1 _ j process 1 input notifyUserInput setState process data notifyDataChanged j getState repaint Figure The interaction of objects in the MVC pattern. Model-View Design Pattern The Model-View design pattern MV is a simplified version of the MVC pattern. The MV pattern is a specific variant of the Observer pattern also known as the Publisher-Subscriber . In the MV pattern the View class combines the functionality of the View and Controller classes in the MVC pattern. The View class in the MV paradigm will be familiar to desktop Java GUI programmers even if they don t realize it as typical application Uls make use of it. For example the UI class shown below is essentially a View class in the MV pattern public class MyCanvas implements MouseListener KeyListener public MyCanvas . addMouseListener this addKeyListener this . DESIGN PATTERNS 323 Under the MV pattern application classes may be classified into one of the two component groups the Model The model manages the application s data. It responds to queries from the views regarding its state and updates its state when requested to do so by the views. It notifies the views when the state of the data has changed. the View. The view presents a view of the model data. It responds to user input instructing the model to update its data accordingly. On notification of changes to the model data it retrieves the new model state and renders a view of the latest state of the data. This simpler pattern is perhaps more appropriate to simpler MIDlet applications. It does not overcomplicate the class structure and the application software and indeed the developers working on the application may be organized into two distinct groups one responsible for the UI and the other for the core application logic. It also means that porting the application between different MIDP devices that may utilize completely different UI paradigms for example from a

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.