- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Fortunately for me, I can choose a job where this isn't an issue. I hate being a code janitor, cleaning up everyone's vomit with sawdust.
Admin
I've programmed in Pascal for a while, and typing := for assignment (which is by far the most common operator in most programs) is a bit annoying. The Basic way of using a single operator also has drawbacks, as have been discussed here various times.
So C chose the pragmatic approach of using the simplest token = for the most common operator, even if it resulted in the ugly == for equality. Today, in Unicode, you could probably easily find different suitable characters for both, but if you're limited to ASCII (or characters you can easily type), I still wonder what would be the optimal choice ...
Admin
Admin
Besides, in Java it would only work with booleans and who in his right mind would test booleans using constants?
I wouldn't do this:
I would test them like so:
So the main case advocated here in Java is in itself an example of redundant (and thus bad) code ;)
Even without a highlight on nested assignments, my IDE would still highlight both as being always true or always false (and the variant with == as having being able to simplify).
With two variables, you'd be never get a compiler error either way. So the only scenario you could save some errors by forcing a compile error would be where one of the sides is a functioncall and the other is a variable.
But I actually very seldomly compare two booleans with eachother... I rarely want to test whether the booleans are either both false or both true and have that trigger the same blockstatement. The case where I want to assign a variable and directly test its outcome is slightly more common in the Java-codebases I work with.
Admin
No.
Admin
You are incorrect. You are assuming smugness simply because you disagree with the reasoning. That's idiotic.
You misunderstand the issue. It doesn't matter how well you know the language. People make typos. If you always do it in the "unnatural" order, then the compiler finds your typos, whereas if you do it the "natural" way, you have a bug you may or may not find.
Admin
People have been bandying around the phrase "professional programmer" here.
Professional programmers have the computer catch their bugs.
Professional programmers also know that code is read hundreds of times more often than it is written, so they write their code for other programmers to read. (Only novices worry about writing code to make the computer do what they want. Of course a professional can do that.)
As a matter of professional courtesy to their peers, professional programmers write their code so that (1) it can be read quickly, and (2) hasty readers will form a correct impression of what the code does.
Using a "natural" syntax is part of (1).
If you're worried about uncaught errors of this sort, you're still at novice level. When code readability is your primary concern, you can call yourself professional.
Admin
Admin
Proper Yoda style would be "null aReceiver =" (Null, aReceiver is).
Admin
Admin
But String.replace does not take a regex.
Admin
I'd go further and say that any object that has meaningful "content exists/doesn't exist" states and where no confusion is possible should be treatable as bool. Fortunately, in C++ I can do that. And you can be happy with your language of choice that doesn't allow it. So we're all happy. ;)
Admin
That's nothing, Lyle made a templating library to generate templates.
Admin
Admin
Now, I do wonder where this particular optimization is useful. But please don't take it to mean I claim it's not useful -- I suppose they did have a reason to implement it, they probably don't like wasting their time.
Admin
We used to do that at my old job, using indefinite articles for parameters (aValue), definite values for global variables (theValue) and possesive for for member variables (myValue). It worked rather well, it was easy to see where each value came from.
Admin
You'd think it wasn't C code, almost as if it was a fictional language...
Admin
Japanese is not an Altaic language.
Admin
صورمشبات .مشبات . ديكورات مشبات .صورمشبات http://shomane.blogspot.com/
صورمشبات http://12abjdhoaz.blogspot.com/
Admin
Admin
Even if you happen to like the "const == variable" syntax and find it perfectly easy to read and parse, it doesn't actually solve the alleged problem, so that's not a good reason to give for using it. Just say you like it. If you're actually trying to solve this problem then:
a) use a language that doesn't permit this; or b) configure your compiler to issue a warning or error if you accidentally do this; or c) configure your source control system to refuse check-ins that use this syntax you've decided to disallow; or d) periodically run a source checker to look for this and any other construct you've encountered that causes you problems.
Any of the above methods will be more effective at actually resolving this issue, and will do so consistently.
Admin
There are an infinite number of empty strings and all strings so the first example should not halt. If it did however it would return "BobBobBobBobBobBob"....
Admin
What he wrote.