1 / 10

Mô hình Model-View- ViewModel

Mô hình Model-View- ViewModel. Nhóm H4: Lady Lên Miss Long Thím Quý Mr. Hải. 1 - Why?. Tăng tính hiệu quả trong sự tương tác giữa designer và developer. Tăng khả năng sử dụng lại các component. Thay đổi giao diện chương trình mà không cần thiết phải viết lại code quá nhiều.

solana
Download Presentation

Mô hình Model-View- ViewModel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MôhìnhModel-View-ViewModel Nhóm H4:Lady Lên Miss Long ThímQuý Mr. Hải

  2. 1 - Why? • Tăngtínhhiệuquảtrongsựtươngtácgiữa designer và developer. • Tăngkhảnăngsửdụnglạicác component. • Thayđổigiaodiệnchươngtrìnhmàkhôngcầnthiếtphảiviếtlại code quánhiều.

  3. Wrong thinking: • MVVM chỉthíchhợpvớicác project cógiaodiệnphứctạp. • MVVM sẽlàmphình to kíchthướccũngnhư chi phíđốivớicácứngdụngnhỏ. • MVVM khôngcânbằng.

  4. 2 - What?

  5. 2.1 - Model • Model làcácđốitượnggiúptruyxuấtvàthaotáctrêndữliệuthựcsự. • Đơnvịcủa Model chínhlà Class. • VD: class Customer dùngđểlưutrữcácthông tin vềkháchhàng.

  6. 2.2 - ViewModel • ViewModellàlớptrunggiangiữa View và Model. ViewModelcóthểđượcxemlàthànhphầnthaythếcho Controller trongmôhình MVC. Nóchứacácmãlệnhcầnthiếtđểthựchiện data binding, command. • ViewModelkhôngmôtảgiaodiệnsẽtrôngnhưthếnào. Nóchỉmôtảcáchmà View hoạtđộngvàthông tin nàosẽđượccungcấpchongườidùng.

  7. 2.3 – View • View là phần giao diện của ứng dụng để hiển thị dữ liệu và nhận tương tác của người dùng. • Mộtđiểmkhácbiệt so vớimôhình MVC, là nó có khả năng thực hiện các hành vi và phản hồi lại người dùng thông qua tính năng binding, command.

  8. Sựkếtnốicácthànhphầntrong MVVM. • Bước 1: Tạomẫuchophần View vàgiữchocác View class táchbiệtkhỏiViewModel. • Bước 2: Cáctínhnăngcủa View đượcđịnhnghĩatrongViewModel. • Bước 3: Mỗi element nằmtrong View đềuđượckếtnốitớicác Properties trongViewModelbằng data binding. • Bước 4: ViewModelsẽlấydữliệutừ Model.

  9. Một điểm cần lưu ý là trong mô hình MVVM, các tầng bên dưới sẽ không biết được các thông tin gì về tầng bên trên nó. Như hình minh họa dưới đây:

  10. Comparing the MVC and MVVM • MVC và MVVM hướngtớinhữngloạiứngdụngkhácnhauhoàntoàn. • MVC for web application. • MVVM for desktop application. • Model: bahave the same way in either pattern • View • In MVC only display data and perform basic client side UI duties usually with JavaScript. • In MVVM have a rich databinding and validation framework.

More Related