A Look at Functional Refactoring

Refactoring is a common task for developers.. hopefully anyway. It keeps code cleaner, more maintainable, and reduces code duplication. It also allows for code to be extended more easily, saving us time in the long run.xkcd - The General Problem (https://xkcd.com/974/)There are many approaches we…

Read this article

The Rules Pattern (How to Drop Your Guard)

In your travels as a programmer, you will more than likely come across a body of code that looks a little something like the following:public bool CheckSystem(Computer computer) { if (computer.Ghz < 3) { return false; } if (computer.Ram < 4) { return false; } if (computer.DiskSpace < 10) { return…

Read this article

Keep Your Collection Setters Private

When exposing properties of a class, you may find yourself immediately exposing a public getter and a public setter. This is a very common approach, especially in anemic models. However, this approach can be problematic when applied to collections. Allowing consumers of your collection to freely modify the entire collection…

Read this article

Prefer readonly to const

I was recently reading Effective C# by Bill Wagner. In the book, the author makes the statement that we should prefer readonly to constants. I wasn't immediately able to piece together why we should, I mean, what's even the difference between the two? To answer this, let's first discuss how…

Read this article