There are a lot of different design patterns. You can find a pattern for every situation. Should we use them whenever we can?
Of course not!
While design patterns generally should improve our code in theory, in practice it’s not uncommon to find a lot of misused and wrongly implemented design patterns.
The most common mistakes happen when people learn design patterns and try to implement them everywhere without the real need for them. The most important part of applying patterns to your codebase is knowing when and where to apply each pattern.
You can easily find the implementation anywhere on the internet. Even multiple implementations of the same pattern. But if you implement them just for the sake of the pattern, you will probably do more damage to your project.
So we’ve decided to go over the most commonly used patterns in C# and to explain where you can apply them and give some nice examples to give you some context.
Here are what we think are the most useful patterns in C#:
- Builder Design Pattern and Fluent Builder
- Fluent Builder Interface With Recursive Generics
- Faceted Builder
- Factory Method
What is your favorite design pattern?