DEV Community

Discussion on: Eliminating Nulls in C# with Functional Programming

 
seangwright profile image
Sean G. Wright

Ya, strict constructors, guard clauses, and immutable state (or at least protected invariants) can go a long ways towards evicting null from your codebase (except where it's appropriate, of course).

If we take an Onion architecture approach for our application, and guard against nulls on the outside of our domain, then we can be safe from it within our business logic, which is where we typically have issues with null.

I like that there are many different ways to protect against or at least carefully handle the case of reference types with null values.

Thread Thread
 
integerman profile image
Matt Eland

That's typically what I gravitate towards - validating on public methods in public classes - then farming things out to private methods or internal classes.