닷넷 패턴 따라잡기 Part1. ux패턴

1,596 views

Published on

WPF, Silverlight, Prism

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,596
On SlideShare
0
From Embeds
0
Number of Embeds
366
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

닷넷 패턴 따라잡기 Part1. ux패턴

  1. 1. 닷넷 패턴 따라잡기 Part1. UX패턴
  2. 2. 1 RIA 패턴 (끝판 왕) 완전 분석 2 WPF MVVM(With Prism) 패턴 따라잡기 3 SL MVVM과 Prism이 만났을 때
  3. 3. 1. RIA 패턴 (끝판 왕) 완전 분석
  4. 4. • Testabiltiy ( ViewModel) is easier to unit test than code-behind or event driven code)• Clear seperation between UX designer and developer• Increases the "Blendability" of your view• Model never needs to be changed to support changes to the view• ViewModel rarely needs to be changed to support changes to the view• No duplicated code to update views
  5. 5. View ViewModel Model• User interface• Window, UserControl, Page or DataTemplate• DataContext is the ViewModel• Little or no code-behind• Updated via data bindings• Command Sources• Behaviors
  6. 6. View ViewModel Model• Abstraction of the View• Adapts Model to View• Maintains State• Exposes properties the View binds to (data and ICommand properties)• Exposes methods View behaviors can call• Loose coupling and testability is the high order bit • Stay away from calling singletons • Stay away from creating up dependencies • Stay away from launching dialogs directly • If not using TDD or BDD, test your ViewModels early on
  7. 7. View ViewModel Model• Your domain• Data objects – DTO, POCO – Generated data model – Generated proxy model• Service Layer – Repositories – Business objects
  8. 8. 1. 코드 비하인드에 대한 작업을 줄이거나 없어야 한다.2. UI(View)의 입출력은 ViewModel과 바인딩되어 있어야 한다.3. ViewModel에 INotifyPropertyChanged 구현4. ViewModel에 로직(behavior)이 있어야 한다.5. Model에 View에 대한 상태값이 있으면 안된다.6. View와 관련이 없는 정보는 Model에 존재하여야 한다.7. ViewModel이 테스팅에서의 주체가 된다.8. 이벤트를 지양하고 Command를 사용한다
  9. 9. 1. 개인 코딩 스타일에 따른 표준 확립의 어려움(이벤트 처리)2. 간단한 UI 프로젝트에 M-V-VM 패턴은 최악이다.3. 기존 개발자가 새로운 개념을 이해하는데 시간이 오래 걸린다.4. 디자이너도 어느 정도의 학습이 필요하다
  10. 10. PP
  11. 11. 2. WPF MVVM(With Prism) 패턴 따라잡기
  12. 12. • Routed Commands – Built in commands like Copy, Cut, Paste – Custom commands – Typically uses the CommandManager – Not used in MVVM – Many routed commands and cause poor performance – Routed commands are great for document centric applications like a text editor• Commands in MVVM – Not routed. Use data binding to directly connect source & target – Can use the CommandManager
  13. 13. • Separate the invoker and logic that executes the command• Provides indication whether an action is available• Are exposed in the ViewModel as ICommand properties• Enables the View to invoke logic in the ViewModel View ViewModel Save Data Binding ICommand Property
  14. 14. • Command sources ButtonBase, MenuItem, Hyperlink, InputBinding, KeyBinding with KeyGesture, ListBoxItem• Classes that implement ICommandSourceICommandSource PropertiesName DescriptionCommand Gets the command that will be executed when the c ommand source is invoked.CommandParameter Represents a user defined data value that can be pa ssed to the command when it is executed.CommandTarget Only applies to routed commands, normally not used in MVVM. The object that the command is being exe cuted on.
  15. 15. • Classes that implement ICommand• RelayCommand & DelegateCommand• Custom classesICommand MethodsName DescriptionExecute Defines the method to be called when the command is invoked.CanExecute Defines the method that determines whether the co mmand can execute in its current state.ICommand EventsCanExecuteChanged Occurs when changes occur that affect whether or n ot the command should execute.
  16. 16. ViewModel Command SourceButtonBase, Hyperlink, M Execute ICommand PropertyenuItem, InputBinding, K eyGesture, ListBoxItem Execute (Action)
  17. 17. CommandManagerRequerySuggestedEvent ViewModel CommandSource ButtonBase, Hyperlink, ICommand Property CanExectueMenuItem, InputBinding,K eyGesture, ListBoxItem CanExecute (Predicate)
  18. 18. • RelayCommand, RelayCommand<T> – Uses CommandManager which uses callbacks for CanExecute• DelegateCommand, DelegateCommand<T> – Does not use CommandManager, must implement CanExecute logic• Others or different flavors
  19. 19. DEMO
  20. 20. 3. SL MVVM과 Prism이 만났을 때
  21. 21. DEMO

×