So, i just discovered Partial Class. Well, actually, Partial is a modifier and not just for Class. But i happened to be excited to use it for Class right now.
Then again, i didn't actually discover it just now. I've seen it before, perhaps many times. It just never clicked, or for whatever reason, i never saw too much value in it. Now i do.
Some time ago, someone taught me one of his own practices: If the code doesn't fit on one screen, split it into another function. He was using C++, and 20 years ago, that really helped with reading code.
I never picked up that practice exactly, but the idea still rings true. Long routines are hard to read and often should be split. I often split things by function, and have many subs and functions with just a line or two, where the purpose of splitting it was just to give it a descriptive name and be kind to the next person (probably me) who looks at the code.
But this idea extends further. Often i'll have Form1.vb itself as some long winding file impossible to navigate without knowing the process. Yeah, there are the dropdowns on top of the editor that i never use, but they do not help with conceptualizing what goes together. That's what Modules and Classes are for.
Modules are okay but have no shared context. So, i need a class. But creating another class means it has its own context. If i want logging to continue in the other class (because it's really just an extension of the current class) i need to pass it a reference to the log, or any other object it wants to use. That's might be okay, except it breaks some of the ideas of encapsulation, can lead to other issues, and it needs to be instantiated, which seems silly for the task at hand.
A second look made me realize that i did not need another class in this case. I just wanted a second file for the purpose of organization. Enter Partial Class. I just changed Class <new class> to Partial Class Form1 (note to self that i'll probably ignore: that really does need a better name) and poof, i'm done. (Well, actually, i also needed to remove the sub new and the variables to hold the passed objects.)
I'm so much happier now. I got organization down so people can understand the logical sectioning of the code and yet kept it as one class, for there is no reason for it to be otherwise. The only downside is that looking at a routine name will not tell you which file it is in. Well, unless you know what it does.