Coming from non-O background in Matlab, I'm looking at doing some of the tasks that make me # Best practice method for #
I have a class, which imports data from a source, and it forms it among other things, in an array of intents. I want to do some operations on this array. To keep it simple, I can say that I want to take the average of all the values. The way I see it, I have three options:
- The array is part of the microse, so I can return the MyArray to the average MyArray.
Double Array Average = MyClass.ArrayAve; -
I can develop a stable class, gives me the
the average of the average by double arrays = average. Array.myArray; -
Apparently there is a way in which I can use the heir or the interface, so that I can run a special task Let's create the class, the ID by providing this new class immediately, this array:
operator class = new operator class ();
oc.data = MyClass.MyArray;
Double Array Average = o.ArrayAverage ();
Increasing the class seems risky, because it is also responsible for importing and formatting data. If I add all data processing for it then I can be quite big, and it will not be straightforward for other people to add-to and endeavor. Work with me
Future codes will require more complex operations on the array, and I do not know what they will be at this time. I will use for some basic functions in future programs, which will be useful as part of the stable class - complex people will be redundant.
Allows separate classes for data processing. Import / formatting classes can provide both general and specific functions to remain separate, but at the cost of running another variable in the code, That seems to me a little messy.
If you have thoughts about it!
You can write the processing you want. This will put the processing into a separate class from the data, and if your object hierarchy allows, then it will allow later methods to use the same method in other ways. Note that if you go this route, you will need to provide publicly enough information for the extension methods (because they are not a part of the class, they are private Or protected member).
Comments
Post a Comment