My main problem is that my tool grows and grows and I start loosing the focus on the different parts of my code. The main-Form got a docked tabControl at fullsize. I got 5 different tabs with for really different functions. So I can say my tool is splitted into topics by tabs.
My thought now was to split my code into classes for each tab. Would that be a bad practice?
How it currently looks:
namespace MyTool
{
public partial class FormMain : Form
{
// GENERAL CODE
// ... MAIN-EVENTS
// ... CALCULATIONS
// ACCORDING TAB1
// ...
// ...
// ACCORDING TAB2
// ...
// ...
// ACCORDING TAB3
// ...
// ...
}
}
Im for sure already working with different classes to get some oop into it. But my idea is to create some more classes with a tagged name just to split my code like this:
namespace MyTool
{
public partial class FormMain : Form
{
// GENERAL CODE
// ... MAIN-EVENTS
// ... CALCULATIONS
}
public class T_TABNAME1
{
// EVERYTHING FOR TAB1 HERE
// ACCESS TO ALL CONTROLS FROM TAB1 ??
}
public class T_TABNAME2
{
// EVERYTHING FOR TAB2 HERE
// ACCESS TO ALL CONTROLS FROM TAB2 ??
}
public class T_TABNAME3
{
// EVERYTHING FOR TAB3 HERE
// ACCESS TO ALL CONTROLS FROM TAB3 ??
}
}
For sure with new files, not into a single one. This way I could get more readability into my code. The only problem with this is how to access all my controls on every single tab. I know I can use properties in general to set something like texts for labels. But what about listviews, comboBoxes, button-states etc.?
As I said: The first big question is if this even makes sense. If not, are there other ideas how to get own areas for the tabs?
If yes, the question would be: how to get access to all of my controls of a tab? As you can guess we arnt talking about 2 or 3 controls. Its rather about 20-30.
I appreciate every help here, thanks a lot.
Place a UserControl on each tab.