jeudi 26 octobre 2017

Is storing raw data with the result object bad practice?

I have a class that is already very long and that I'd like to split. At one point I do a lot of calculations (based on two integer and two Lists) and store the results into a result object.
My idea was to pass the integers and Lists to the "result object", do the calculations inside its constructor and assign the results to its instance variables (I would pass the result object in a subsequent step). This way I keep the code that is just a means to an end (needed only once to do the calculations) at the place where the result is stored.
This also keeps methods and data together at one place instead of two, which increases modularity. It leaves me with one class that has it all: the raw data, the algorithms and the results. I just need to assure to pass the parameters to the constructor.

Yet my gut feeling tells me that this is a design flaw. So, is storing raw data with the "result" object bad practice? Should I make the calculations inside the object or outside and simply use it as a DTO?

Aucun commentaire:

Enregistrer un commentaire