So you’ve heard of the Open/Closed principal of SOLID — and Command Query Separation. But you’re not completely onboard with how to actually do this in practice.
Also, you’re aware that it’s considered a violation of OCP if you have to modify an existing class to accommodate new behaviour. The desired action would be to just create a new class that implements the new behaviour or functionality you’d like to add to the application.
In this article we’ll achieve the following

  • Dispatch commands that will be handled by some other “handler” class
  • Add new commands without modifying existing classes
  • Dynamically invoke handlers when a command is dispatched

#c #c# #c++ #programming-c

Dynamic command dispatching in C#
3.45 GEEK