Alexybubble
Alexybubble
CC#
Created by Alexybubble on 5/19/2023 in #help
❔ How to handle a group of variables that need to stay together within a class?
How should I handle a group of data that needs to stay together within a class? The data is a set of ~20 variables from an external object that holds a large amount of data both necessary and unnecessary for the task that the class is doing (the object has ~50 variables total), so I'd like for the class to only take the data that it needs from the object. The class also needs to be able to have multiple sets of this info at once while handling each set individually, so I need to be able to make an array that has each entry contain all of the neccessary data. Also, the data needs to be able to be changed by the class, but doesn't need to be able to be changed by other classes. What's the best way of doing the above? I've been using a struct to hold the info so far, but when I try to find a solution to this problem created by other refactoring, I keep seeing that this is apparently an awful solution and that I should turn it into a class, but since the class is never refrenced by another class outside of initially running it, I'd really like to keep the data within the class that uses it, if possible.
20 replies