Consider the code bellow:
if (variable == 3) {
// do something
}
This would be the way most of us write conditionals.
However, some language would also allow to write something like this:
if (variable = 3) {
// ALWAYS do something :)
}
It just one symbol difference, but the effect could be VERY different.
All of a sudden, you don’t compare anything, in JavaScript, for example, you will blindly assign 3 to the variable and always execute the code.
So, here comes “the force”:
if (3 == variable) {
// Yoda conditions
}
This is called “Yoda conditions” and it will make the previous mistake virtually impossible. It reads awkward (at first), but after some practice it could become your second nature.
Similarly, in Java you could avoid string related Null Pointer Exceptions by writing Yoda string conditions:
if ("value".equals(variable)) {
// do something
}
You could discuss the concept here: https://testingcoder.hashnode.dev/embrace-the-force-yoda-conditions