java - Not using a return value of a method , Is it bad design? -


following example code , checkuserguess method belongs board class.

public string checkuserguess(string aguess) {    // processing     return result_of_a_guess; } 

i have simpleguessinggame class consumes method , satisfied processing method does. not use returned value.

another class complexguessinggame consumes method , uses value returned method further processing.

so have 2 cases , 1 return value used , other ignored. common occurrence or point bad design ?

when need this, chances method 2 things of value caller:

  1. validates something, or produces side effect, and
  2. computes result returned callers

since users need #1, while other users need both #1 , #2, may idea split method in 2 parts, this:

public void validatekuserguess(string aguess) {    // processing } public string checkuserguess(string aguess) {     validatekuserguess(aguess);    // additional processing    return result_of_a_guess; } 

now users wish ignore return value not required "pay" cpu , memory computing value going discard anyway.


Comments