The single-responsibility principle - piece of software should have only one responsibility The open–closed principle - things should be open for extension but closed for modification The Liskov substitution principle - changing interface implementation should not brake software The interface segregation principle - it is better to have more specialized interfaces than single big one The dependency inversion principle - dependencies should be abstracted via interfaces Further read:
https://en.wikipedia.org/wiki/SOLID
Pattern matching is used for:
testing expression to check if some value have certain characteristics safer compare because ‘==’ and ‘!=’ can be overloaded Examples:
a is int number sequence is IList<T> list switch statement:
command switch { Operation.SystemTest => RunDiagnostics(), Operation.Start => StartSystem(), Operation.Stop => StopSystem(), Operation.Reset => ResetToReady(), _ => throw new ArgumentException("Invalid enum value for command", nameof(command)), }; switch with ranges:
tempInFahrenheit switch { (> 32) and (< 212) => "liquid", < 32 => "solid", > 212 => "gas", 32 => …