3 ms·
> What is the difference between a design pattern and a language idiom? A design pattern is simply a name given to the obvious solution given to a common probl
by jd 18y ago
> What is the difference between a design pattern and a language idiom?
A design pattern is simply a name given to the obvious solution given to a common problem. By giving it a name it becomes much easier to talk about / understand the code. Once you know that a class is a proxy class, you don't really care what the methods do anymore, you just dive in and see to which classes the real work is delegated. So one word "proxy" tells you exactly what 400 lines of boilerplate does.
A language idiom is different. The purpose of language idioms is to clearly and succinctly express common concepts. The language designers think of a "best" solution, and give it a name.
So, really, when you have a bunch of people writing the same code to solve the same class of problem, you give that code a name and call it a design pattern. Patterns emerge AFTER the language is used. Language idioms try to capture the essence of the problem, such that no patterns are necessary.
At least, that's how I look at it.