Monday, February 22, 2016

partials instead of regions?

This touches on an alternate way to break up a fat C# class without using regions and in particular if you inherit from multiple interfaces maybe you could have a different partial to satisfy each interface's neediness. I'm not sure this is better honestly. In my imagination I thought of code-generated code that cannot compile until some love is given to it at a dev-rolled partial. I shared the following over that stupid Slack app that explains my thoughts:

  • In particular the idea of using partials in lieu of regions in a fat C# class. I'm not sure it isn't even more gross though. And yet... In the typical code generation pattern one associates with partials wherein one partial is generated code and one partial is a hand-rolled extension, you could force the hand-rolled extension to have certain requirements by using this interface trick and thus babysit devs a little bit. i.e. “You must write your own error handling method and the code generation tool ain’t gonna do it for you.” ...that sort of encouraging straitjacket ...if you're playing God and making a T4 template abomination anyways, why not go apeshit?

No comments:

Post a Comment