Is it worth to write this piece of code:
RelayCommand _saveCommand;
public ICommand SaveCommand
{
get
{
if (_saveCommand == null)
{
_saveCommand = new RelayCommand(this.Save);
}
return _saveCommand;
}
}
instead of just returning new object every time:
public ICommand SaveCommand
{
get { return new RelayCommand(this.Save); }
}
From what I know command getters are used pretty rarely and RelayCommand‘s constructor is pretty quick. Is it better to write longer code?
I like the null coalescing operator
It returns the left-hand operand if the operand is not null, otherwise it returns the right operand.