java - Is creating a lot of private classes bad style? -


i doing project in java has lot of methods require multiple return objects. have keep creating private classes encapsulate return objects. objects make sense fontresult in code return font name , font size example creating new objects each return type require feels wrong , somehow trying circumvent how java should written. wrong or fine this? should structuring code in more of tell-dont-ask approach?

an example follows:

string test = "hello"; stringresult result = getinformation(test); int length = result.length;  private stringresult getinformation(string test) {   int length = test.length();   char firstchar = text.charat(0); }  private class stringresult {   int length;   char firstchar;    stringresult(int length, char firstchar) {     this.length = length;     this.firstchar = firstchar;   } }  

while necessary have "multiple return objects", sign indicating passing around information. possible situations:

  1. you pass lot of data 1 object other objects tightly coupled -> should have 1 class.

  2. you passing around information nobody uses -> erase it.

  3. you passing around information between methods inside class should private field of class.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -