Author: Marinko Spasojevic

C# Design Patterns – Faceted Builder

In the previous two articles, we were talking about Builder Design Pattern and Fluent Builder With Recursive Generics. We recommend reading at least the first one for a better understanding of the Builder Design Pattern. The second one is the upgrade to the first article and if you want to learn more about using recursive generics with the Builder Pattern, then we recommend reading that one as well. Builder Design Pattern and Fluent Builder Fluent Builder Interface With Recursive Generics  Faceted Builder (Current article) Factory Method Singleton Adapter Composite Decorator Command Strategy This article is part of the series...

Read More

C# Design Patterns – Fluent Builder Interface With Recursive Generics

In the previous post, we have been talking about Builder and the Fluent Builder design patterns. So, we strongly recommend reading that one before you continue with this post if you are not familiar with the Fluent Builder pattern. In this post, we are going to get a Fluent Builder to a higher level and show how we can use generics while inheriting from another Fluent Builder. When builders inherit from other builders, nothing particular is going to happen and everything should remain the same. But if one Fluent Builder inherits from another one, well, we are going to...

Read More

C# Design Patterns – Builder Design Pattern and Fluent Builder

The Builder design pattern is a creational design pattern which lets us create an object one step at a time. It is quite common to use this pattern when creating a complex object. By using this pattern, we can create different parts of an object, step by step, and then connect all the parts together. Without this pattern, we can end up with a large constructor to provide all the required parameters for constructing our object. That could lead to quite unreadable and hardly maintainable code. Furthermore, a constructor with lots of parameters has a downside to it. We won’t...

Read More

SOLID Principles in C# – Dependency Inversion Principle

The basic idea behind the Dependency Inversion Principle is that we should create the higher level modules with its complex logic in such a way to be reusable and unaffected by any change from the lower level modules in our application. To achieve this kind of behavior in our apps, we introduce abstraction which decouples higher from lower level modules. Having this idea in mind the Dependency Inversion Principle states that High-level modules should not depend on low-level modules, both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions. We are going to...

Read More

SOLID Principles in C# – Interface Segregation Principle

The Interface Segregation Principle states that no client should be forced to depend on methods it does not use. So, this is the basic definition which we can read in many different articles, but what does this really mean? Let’s imagine that we are starting a new feature on our project. We start with some code and from that code, an interface emerges with the required declarations. Soon after, the customer decides that they want another feature which is similar to the previous one and we decide to implement the same interface in another class. But now, as a...

Read More