I'd like to know if this is the preferred way to design a class; if not what's wrong with it and what's a better option?
class Calculator {
   public Calculator(Input input) {...};
   CalculatorOutput output;
   class CalculatorOutput {
   private CalculatorOutput() {} //private constructor - so no one other than Calculator can instantiate this class
   Double someCalcStuff;
   List<Double> someOtherCalcStuff;
}
    public void calculate() {
    CalculatorOutput op = new CalculatorOutput();
    //..after this function populates the someCalcStuff & someOtherCalcStuff; it just returns an instance of CalculatorOutput
}
...
return op;
}
//usage
Calculator.CalculatorOutput result = new Calculator(input).calculate();
for (Double d: result.someOtherCalcStuff) {...}
The reason I have CalculatorOutput as an inner class of Calculator is b/c it's got no other purpose or context than returning the calculator's output. I have CalculatorOutput's members as public b/c I don't really see a point in making them private , and then accessible via a getter/setter...Since I don't expect this inner class to be inherited, or do any other functionality mentioned in this post: Why use getters and setters?
The user cannot instantiate the inner class (private constructor), so I don't see a real drawback in creating public accessible members of the inner class (CalculatorOutput)
Specific questions:
- Is this approach bad? why?
- What's a better approach to achieve this?
 
     
    