lundi 15 mars 2021

Do I need Yoda Conditions really?

Some programmers tell me that I need to always write code in Yoda Conditions, but I don't agree.

int lhs = ...;
const int rhs = ...;
if (rhs = lhs) ...     

Yoda Conditionas are harder to read and understand, and it is yet to sort out every bug code. This is an example.

int lhs = ...;
int rhs = ...;
if (rhs = lhs) ...

In my opinion, not enforcing programmers to use Yoda Conditions but adding a compiler flag assignment within conditional expression as an error sorts out the remaining problems completely, not to mention the easier code understanding.

Do I still need Yoda Conditions?

Aucun commentaire:

Enregistrer un commentaire