I'm doing refactoring/review of a Java application
When I'm doing that I show that some of method has
return values such as Object
, String
, Boolean
, etc., but
return values are not used in any places. Only have done the method calling.
So, I'm just wandering keeping them as it is will cause the performance issue for application.
Should I change them to void or keep them as it is?
I do not think that there would be a performance penalty to keeping the return types like they are.
That being said, I think that you should still remove them. The reason is that they are essentially dead code. There might be unknown bugs lurking in those methods revolving around the return types - unknown because they are not used. This is a potential danger if someone decides to use them one day.
Furthermore, the maintenance burden is increased if you keep them: Everytime someone touches one of these methods, she has to (unnecessarily) think about the return type.
This essentially boils down to YAGNI.