KBD

Keith Devens .com

Thursday, May 17, 2012 Flag waving
Our Constitution was made only for a moral and religious people. It is wholly inadequate to the government of any... – John Quincy Adams
← If they only used DvorakNo cents for you →

Daily link icon Monday, May 13, 2002

Anti-idioms

Really cool post from Adam on programming anti-idioms.

Knowing a programming language's idioms is the key to being fluent in that language.
It is also important to know what not to do. Just because a language allows a certain coding style doesn't mean that style is a good one.

The anti-idiom he uses as an example is one where you can butcher C++'s exception handling to be able to "return" a value of any type. Read the post for specifics... however, I say that this type of thing is actually an anti-pattern, not an anti-idiom. In fact, I don't think you can even have "anti-idioms". An idiom doesn't really carry a value judgement along with it; an idiom is just a thing people commonly do. [Design] Patterns on the other hand, do carry a value judgement.

I like the way wiki says it, "an AntiPattern is a pattern that tells how to go from a problem to a bad solution", whereas a pattern tells us how to go from a problem to a good solution.

Seen on LtU.

Another reason this is an anti-pattern instead of an anti-idiom which I didn't mention before is that this is a large-scale design rather than a small scale bit of code that would be called an idiom.

Ehud brings up a good possible use for the term anti-idiom:

Perhaps the term anti-idiom should be reserved for incorrect code people repeatedly produce, esp. if related to well known idioms.

Maybe something like for(n=0;n<=count;n++){...} would be an anti-idiom? Or to use Adam's example, something like while(*++n = *++m);?

← If they only used DvorakNo cents for you →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

May 2012
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Acknowledging the Arrival of Peak Government

In many ways, Peak Oil is​responsible for this new​uselessness of the big g...

Revence: May 16, 6:35am

new⇒Tab EXSPLOSION

Right now, I, too, have too many​tabs open. A rough count says​25.
Right. ...

Revence: May 16, 6:21am

George W. Bush: ‘I’m for Mitt Romney’ - ABC News

A marked difference (departure,​even) from the KBD of eight--yea,​even four...

Revence: May 15, 1:55pm

WebOb — WSGI request and response objects

Google App Engine forces one to​learn these....

Revence: May 15, 1:52pm

Generated in about 0.188s.

(Used 8 db queries)