On 8/7/2012 3:02 PM, Steven D'Aprano wrote:
On Sun, 05 Aug 2012 19:44:31 -0700, alex23 wrote:

I think you've entirely missed the point of Design Patterns.

Perhaps I have. Or perhaps I'm just (over-)reacting to the abuse of
Patterns:

http://c2.com/cgi/wiki?DesignPatternsConsideredHarmful

or that they are a crutch for underpowered languages:

I still remember reading an article something like "Implementing the Composite Pattern in C++". The example for the discussion was Pictures that could contain sub-Pictures as well as Graphic elements. I eventually realized that a) this is trivial in Python, b) the article was really about how to lie to a C++ compiler, so it would accept recursive heterogenous structures, and c) I preferred Python.

http://c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures

I think that as languages get more powerful, "Design Patterns" just
become language features, and people stop talking about them. Nobody
talks about Function Pattern, but everyone uses it. In Python, we don't
talk about the Iterator Pattern. We just use iterators.

In pre 2.2 Python, there was talk about the pattern (but not with Capitals) and how to lie to the interpreter with a fake __getitem__ method.

I'm pretty sure that people could talk about good coding design before
the Gof4. As you say, they didn't invent the patterns. So people
obviously wrote code, and talked about algorithms, without the Gof4
terminology.

'Divide and conquer' is an old, descriptive name for an algorithm action pattern. It is only incidentally about static structures.

'Dynamic programming' is a rather opaque name for a) an action patter for using the optimality principle* (when applicable) and b) not disposing of data one still needs.

* the best path from A to B that passes through C is the best path from A to C plus the best path from C to B.

Lisp is based on a simple data pattern (or is it a principle): collection (of dicrete items) = one item + remainder, used to both construct and deconstruct. Python iterator embody the the same principle. next(iterator) = iterator: return one item and mutate yourself to represent the rest -- or raise StopIteration.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to