Hacker News new | ask | show | jobs
by paganel 5446 days ago
> Observer, the Adapter, or the Visitor

It depends on the programming language one uses, really. You won't find many references to these patterns on Python's mailing list (or at least I didn't when I was new to the language and used to spend a lot of time there, ~6-7 years ago). Also, when I've tried to learn Lisp or Erlang I didn't find any mentions to such particular patterns (or maybe only in passing), the focus was on something else. And I'm sure there are a lot of other languages outhere who don't bother with patterns.

3 comments

You did not hear about observer, but you probably heard about publisher/subscriber (most gui frameworks use this, even wxPython with pubsub).

Adapter is a generic name. Compatibility modules that enable python code to run with python 2 and python 3 are adapters. For example: https://github.com/bartdag/py4j/blob/master/py4j-python/src/...

As for the visitor pattern: http://docs.python.org/library/compiler.html#module-compiler...

All languages have patterns. Case analysis is a common pattern in Lisp code I've seen. Another one is map-reduce. Tags are another one.

They're just not called design patterns. But note that the things in GOF weren't called design patterns in C++ until 1995 either (the GOF book largely predates real use of Java). They were called techniques, or just things you might see in multiple projects.

Every language has design patterns. The patterns are different depending on the language, though. You don't use the observer pattern much when you've got proper delegates (or closures), for example. Design patterns are just the things you end up doing over and over in a language. MVC is a design pattern. Even something like Rails itself could be said to be a codifying and standardization of a set of design patterns.