Just a quick question regarding good programming practices,
Performance aside, how much of a good/bad idea could something like this be? I am oversimplifying the problem to get my point across, but is something like this totally wrong?
public void methodWithInputString(String data) {
// do something with data
}
public void methodThatCallsTheAbove() {
methodWithInputString(
// lambda with no input and a string as output
(() -> {
if (this.conditionIsTrue)
return "Condition is true";
else
return "Condition is false";
}).apply();
);
}
The alternative would simply be:
public void methodThatCallsTheAbove() {
if (this.conditionIsTrue)
methodWithInputString("Condition is true");
else
methodWithInputString("Condition is false");
}
I understand that the second is the obvious/correct approach but in a situation where using the first one makes my code cleaner is it still a nonsensical thing to do?