currently learning

Currently Learning - Functional Principals in C#

I have been exploring functional programming lately and looking at adding some functional approaches to a sub-set of a codebase I'm in the process of refactoring, particularly around making some of the core domain model immutable to ensure less side affects and make testing easier as an added bonus.

I came accross the course Applying Functional Principles in C# by Vladimir Khorikov on Pluralsight and spent some time working through its content and applying some of the techniques and patterns to the codebase. Vladimir Khorikov, a Microsoft MVP, shares knowledge on how to avoid primitive obsession, refactor to an immutable architecture by applying an 'immutable core' with a 'mutable shell', an approach to eliminate nulls and how to refactor away from exceptions.

The existing codebase I'm working on follows a Domain Driven Design approach and I found the content of this course very complementary and applying some of the approaches in this course easy with little to no friction.

One of the more interesting patterns I found during the course was applying the concept of 'Railway-oriented Programming'. Refactoring some methods that had a lot of validating and logging to a more concise Linq style syntax really helped the readabily of some aspects of the codebase.

You can find out more on Railway-oriented Programming in this talk by Scott Wlaschin

Scott Wlaschin - Railway Oriented Programming -- error handling in functional languages from NDC Conferences on Vimeo.

Finally if you decide to start applying some of the core concepts covered by Vladimir in this course, be sure to check out his open source project on Github or get the package on Nuget.

CSharpFunctionalExtensions on GitHub