c# - MVVM Foundation: Why return ICommand when its defined as RelayCommand -
i using samplemodel project mvvm foundation.why icommand
returned when _decrementcommand
declared relaycommand
. know relaycommand
inherits icommand
won't clearer return relaycommand
?
public icommand decrementcommand { { return _decrementcommand ?? (_decrementcommand = new relaycommand(() => --this.value)); } } relaycommand _decrementcommand;
this principle of using least specific type can away with. concrete or specific types liability because more expose things callers don't need know , more need changed (making them implementation detail).
in case, if return icommand, can change underlying command type without breaking callers. can expect callers won't have know more function should know, meaning less break oo principles.
Comments
Post a Comment