Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bconditionhttps://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

Does the question belong on WPSE

No, because this is a general coding idea, it is not specific to WordPress, even though it's recommended by WordPress. In the same vein that WordPress has password security recommendations here, but the topic has nothing to really do with WordPress specifically.

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

Does the question belong on WPSE

No, because this is a general coding idea, it is not specific to WordPress, even though it's recommended by WordPress. In the same vein that WordPress has password security recommendations here, but the topic has nothing to really do with WordPress specifically.

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( https://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

Does the question belong on WPSE

No, because this is a general coding idea, it is not specific to WordPress, even though it's recommended by WordPress. In the same vein that WordPress has password security recommendations here, but the topic has nothing to really do with WordPress specifically.

added 371 characters in body
Source Link
Wyck
  • 18k
  • 15
  • 17

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

Does the question belong on WPSE

No, because this is a general coding idea, it is not specific to WordPress, even though it's recommended by WordPress. In the same vein that WordPress has password security recommendations here, but the topic has nothing to really do with WordPress specifically.

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.

Does the question belong on WPSE

No, because this is a general coding idea, it is not specific to WordPress, even though it's recommended by WordPress. In the same vein that WordPress has password security recommendations here, but the topic has nothing to really do with WordPress specifically.

Source Link
Wyck
  • 18k
  • 15
  • 17

When a someone repeats a question it's not because he is annoying but rather because the answer is not sufficient, even though the answerer thinks it might be.

The question should have been.

Why does WordPress recommend Yoda conditionals ?

Since WordPress does specifically recommends using Yoda conditionals on the Coding standards page.

So like why?

The reasoning is that it prevents logical errors if you make a typo. For example typing 'true = $the_force' will correctly throw an error as opposed to $the_force = true. This was explained in the comment link above ( http://stackoverflow.com/questions/5854317/what-is-the-difference-between-these-bcondition-null-and-null-bcondition )

Is this specific to WordPress ?

No, the suggestion as noted above was just picking up what other languages do.

Does it matter ?

No it doesn't matter, make your code readable and typos usually break things, but ultimately do whatever you feel is a better fit for you.