Reputation: 161
I am newbie in WPF programming world. I have studied Command pattern and I understood it encapsulates a request(any kind of action) and execution can be given to other entity(invoker).
Recently I have been asked interview question showing like above command pattern UML diagram and they asked me to compare with WPF Button class and tell who is Invoker ,who is client, who is receiver, where is command, and where is ICommand.They asked me explain with wpf button and rename all actors on that UML diagram .
I renamed client as button. ViewModel as Receiver, but could not explain invoker, Concrete command. As per command pattern client will create command will give to receiver but in terms of WPF button ... button and view model are totally decoupled.
Would some one help me to understand this?
Upvotes: 2
Views: 563
Reputation: 1638
In a WPF MVVM world
Client -> Application
Invoker -> User (button click)
Command -> ISomeCommand Interface
ConcreteCommand -> SomeCommandA class that implements ISomeCommand
Receiver -> SomeService.DoSomething() logic that gets called inside SomeCommandA
User interaction is usually the invoker. Sometimes an automated process or event can be an invoker, but in this case a User clicks a button invoking the action.
Upvotes: 2