A Proxy Controller for Managers?

All of the systems we design use essentially the same layered architecture. Our top layer is the manager layer. That layer is often consumed directly from our controllers in our ASP.NET projects. This usually results in us writing many thin methods that just call our managers.

But what if we didn’t have to write those methods, what if we had one method that handled the calling of our manager methods for us. Yes, this sounds both good and bad at the same time.

First, we create a controller method.

Then we parse the content of the body.

Parse the parameters passed in.

Get the method using reflection.

Move the parameters from the JSON to the parameter for the method.

Call the method on our manager using reflection. And now we have proxied the request.

While this worked, I don’t know if I’d recommend it, or at least not the version I created here. This ability to automatically bind a controller to a manager could reduce a lot of copy-paste code (which is almost always a good thing), but this might also create some awkward code to deal with. Also, I wonder how this could be modified to better handle different security requirements. While I think this idea is potentially good, I feel my implementation is a little too immature to recommend.

I have heard of others talking about this idea, but I have never tried to do it until now. Part of me questions the value, but this was a fun experiment I thought it would be interesting to try.