Below are the key ideas of how to apply functional principles in C# explained in Pluralsight course by Vladimir Khorikov.
- Immutable Architecture Separate domain logic, Infrastructure(Persister), Service logic. Make the domain logic immutable and functional(input -> output) so as to easily unit test it. Make the infrastructure and service logic as simple as possible.
- Exception Use return value over an exception if it's a known exception. Fail Fast General exception catch should be in a single place to catch all unexpected exception.
- Avoid primitive obsession Utilize value object which may contain validation logic as a single place to check input data.
- Avoid null Use 'NullGuard' library with [assembly: NullGuard(ValidationFlags.All)] option to check not only public method but also private method and properties. Use Maybe<T> around a domain model which is separated from the presentation layer.
- Handling Failures and Input Errors Use value object Try catch at the lowest level Use Railway-oriented Programming => Result<T> and Maybe<T> => Monad.