Reputation: 4125
I'm creating a signal analysis program that plots some data and compares sources and does some operations. I'll have to update the size of some elements of my UI and also create new elements (for example, I have a big plotter, and if user selects X it should to divide in 3 showing more data).
I'm pretty new in Visual Studio and in programming non-numerical stuff in general. I would appreciate enormously hints and advises to create a solid interface.
One of the issues that I currently have is that I've defined 15-20 elements in MainWindow.xaml and its code in MainWindow.cs but it's growing fast and it is a mess. For example, I have a button that loads a file and does a bunch of different operations (reads it, cuts, puts all in lists and then displays it). What do you recommend me to keep the code clean and readable? To create methods at the end of the file? Create separate class files?
I know its not very specific question but I think I'm not the only one that is having this kind of problems. Thank you.
Upvotes: 2
Views: 152
Reputation: 38392
A class with some static helper methods is a start. There are lots of different ways to go with this, but the main point of all of them is your MainWindow.cs should have only enough code to gather information together in the UI and then call on the other layer(we'll call it the business layer) to actually perform tasks or save/load data. MainWindow.cs should be like a seperator between your UI and your business layer. The business layer shouldn't know anything about buttons or textboxes. Instead it might take the string from the TitleTextbox and put it into a SignalFile.Title property of a simple class(called a POCO). You might have one business layer class that deals with operations related to this file, a method for each action you can perform on it.
Upvotes: 1