jeudi 9 mars 2017

Should I strive for either member functions with a single responsibility or minimising the number of member variables?

I have a class called SolarPosition that has many member functions. I currently have a member function called CalculateSolarAzimuthAndAltitude which is a prime candidate for refactoring.

I found that the only way to refactor it to CalculateSolarAzimuth and 'CalculateSolarAltitude' was to add an additional ten member variables, as some preliminary calculations are used by both functions.

Should I be happy with a member function with two responsibilities, or are multiple transient member variables a reasonable sacrifice in order to split it up?

Aucun commentaire:

Enregistrer un commentaire