This question is locked. New answers and comments are not allowed.
Let's take the following code. Assume that every variable is a bool value.
using the JustCode refactoring, the following code pops up:
Well.. do you see the problem?
Hint:
With the first code the first if a! is true, but the second (c ||d||(e&&f) is false.
With the second code DoSomething will be executed, as !a is true, and the other parts does not need to be checked...
The refactoring just makes correct code wrong.
If a join is done in such a case a few more paranthesis must be added...
I doubt a bit that this makes the code easier to read... but after all it would not change the result of the code
if (!a || b) if (c || d || (e && f)) DoSomething(); using the JustCode refactoring, the following code pops up:
if (!a || b && c || d || (e && f)) DoSomething();Hint:
bool a, b, c, d, e, f;a = b = c = d = e = f = false;if(!a||b) if(c ||d||(e&&f)) Console.WriteLine( "This will not be printed."); // just click on "Join nested if statement"
if (!a || b && c || d || (e && f)) Console.WriteLine("Oh no, this should not be printed, what happened?");With the first code the first if a! is true, but the second (c ||d||(e&&f) is false.
With the second code DoSomething will be executed, as !a is true, and the other parts does not need to be checked...
The refactoring just makes correct code wrong.
If a join is done in such a case a few more paranthesis must be added...
if ((!a || b) && (c || d || (e && f)))I doubt a bit that this makes the code easier to read... but after all it would not change the result of the code