KBD

Keith Devens .com

Friday, November 21, 2008 Flag waving
Less isn't more; just enough is more. – Milton Glaser
← 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)
:

November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



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

Recent comments XML

new⇒Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.214s.

(Used 8 db queries)

mobile phone