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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -