Hi Ben!

Glad you liked the article :)

You're right, reflection does lead to lower performance. I read somewhere it takes about x8 longer to instantiate objects and invoke methods using reflection.

Regarding maintenance, it guess it depends on which perspective you take on this.

This simple example is very easy to maintain, because all you do to add functionality, is to create new classes, these can then be tested separately as well.

You can achieve a similar result by using the Event Aggregate pattern.

This way, you'll have a single class, like the dispatcher, where you register events (or commands) and corresponding handlers.

You can use a dictionary for that.

I'll see if I can find the time to write an example of such approach.

Howcome you dislike IoC containers?

Written by

Tech writer with 621K+ views. Sharing my opinion and what I learn. Danish C# backend engineer in FinTech. Ex Big4 senior tech consultant.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store