Live data from Hacker News

Yoda Conditions

en.wikipedia.org

81–83 of 83 posts

Re: Yoda Conditions

#81
post #70

Earlier quoted context omitted.

Counterargument: Do do this if the coding standards for the language/framework you're working in require it. Like WordPress.

Wordpress is a legacy procedural codebase and should not be used as an example of good development practices.

Regardless of your religious convictions, Wordpress still exists and that work has to be done by somebody.

I'd rather it be done by people who care than those that don't.

Re: Yoda Conditions

#82
post #16
post #3

Don't do this. In languages where accidental assignment is possible (i.e. writing if(a=b) when you meant if(a==b) ), configure the compiler or linter to emit a warning in this situation. For example in C, GCC will complain about this when compiling with -Wall, which you should be using anyway.

The real lesson is for language designers, who for some reason love using equals for assignment. Lisp got it right a hundred years ago and nobody learned.

I'd say the issue is keyboard designers, if ':' didn't require shift I bet we'd see it for assignment more often.

Re: Yoda Conditions

#83
post #70

Earlier quoted context omitted.

Wordpress is a legacy procedural codebase and should not be used as an example of good development practices.

Regardless of your religious convictions, Wordpress still exists and that work has to be done by somebody. I'd rather it be done by people who care than those that don't.

How is that a comment on coding standards or best practices? I'm afraid the arguments against procedural code are not religious. Procedural code provides poor encapsulation and modularity. If procedural code was all that great, we wouldn't have needed to have C++, C#, Java, and Objective-C, and any number of other derivative languages. Regardless of my or your opinions, WordPress is a legacy codebase. Procedural code today is all but completely discarded.
Post reply on HN