This is one of the more noteable of today's refactorings where null-propagation was applied.
Before:
private bool CurrentContextHasPlayer() { return _currentViewContext != null && _currentViewContext.AudioView != null && _currentViewContext.AudioView.AudioPlayer != null && _currentViewContext.AudioView.AudioPlayer.Player != null; }
After:
private bool CurrentContextHasPlayer() { return _currentViewContext?.AudioView?.AudioPlayer?.Player != null; }
You might argue that this is an instance of the Feature Envy code smell and maybe you would be right ;-)
Keine Kommentare:
Kommentar veröffentlichen