Any harm when changing the void return type to something else in a commonly used utility function?

if I have a function like

public void usefulUtility(parameters...) { 
    string c = "select * from myDB";
    do_a_database_call(c);
}

which is used in many places, is there any possible harm in changing it:

public bool usefulUtility(parameters...) { 
   string c = "select * from myDB";
   bool result = do_a_database_call(c);
   return result;
}

Could this break any code?

I can't think of anything ... but is this possible?

+5
source share
5 answers

, , , , - . , , , , , , ( ), , , .

.

Action a = usefulUtility;
+3
+2

, , . , - .

, , - , - . , , , , . , - , .

+1

You will need to actually return a String, or at least null for the method to compile. You can no longer finish the method without returning.

0
source

If you want to be absolutely sure that you won’t break anything, give a method that returns a String with a different name and leave the signature of the void method the same.

0
source

All Articles