Code smell – Marker Interfaces
We used the empty ICommand
and IQuery<TReturn>
interfaces in the project code samples to make the code more explicit and self-descriptive. However, empty interfaces are a sign that something may be wrong: a code smell. We call those marker interfaces because they mark a type for some purpose instead of defining APIs.
They may suggest an overly complicated design or misuse of object-oriented principles, reflecting an approach that favors tagging classes over more explicit or meaningful design choices. While interfaces play an integral role in defining contracts and enabling polymorphism, empty marker interfaces can obscure the purpose of a class and erode type safety by not conveying clear intentions or behaviors.
In our case, they help identify commands and queries but are empty and add nothing. We could discard them without any impact on our system. On the other hand, we are not performing magic tricks or violating any principles...