IRouterExtensions #134
-
This code is great and I am learning a lot from reading it. I ran into a question though... Why does IRouterExtensions have 2 partial classes in the same file? I don't understand that. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's a code management pattern I sometimes use to separate out different logical parts. IMHO it makes the code easier to follow when I haven't looked at it for awhile. You'll notice, for example, that in the second partial class there is a private property. That property does not make any sense in the context of any other extension method. Putting the property and the method in a partial class that is separate from the rest of the extension methods quickly makes the point that the property is only used by and useful to the method it is grouped into the partial class with, as well as prevents access to it by other methods in the same class. I could just make two different extension classes, but then I'd have to come up with names for them, and that feels like more effort that just making them partial classes. Keep in mind that while this is a passion project for me, it is sometimes months between putting it down and picking it up again, and I take advantage of anything I can do to make it easier for me to understand what is going on. |
Beta Was this translation helpful? Give feedback.
It's a code management pattern I sometimes use to separate out different logical parts. IMHO it makes the code easier to follow when I haven't looked at it for awhile.
You'll notice, for example, that in the second partial class there is a private property. That property does not make any sense in the context of any other extension method. Putting the property and the method in a partial class that is separate from the rest of the extension methods quickly makes the point that the property is only used by and useful to the method it is grouped into the partial class with, as well as prevents access to it by other methods in the same class. I could just make two different extension classes…