Dmitri Nesteruk
Dmitri Nesteruk

Reputation: 23798

Looking for example of design patterns baked into programming languages

Many programming languages embed design patterns right into the language. I'm looking for the most obvious examples, like Python decorators (Decorator?) or C# events (Observer). Can you give me some more?

Upvotes: 0

Views: 74

Answers (1)

ewernli
ewernli

Reputation: 38625

I've also beein intrigued by this very question and even asked a similar quesiton once: Design pattern as (missing) language feature

Sure, there are some more patterns that simply vanish in other languages.

  • Singleton: in Scala, you can define singleton with the object keyword.
  • Factory: in Smalltalk, classes are first-class and serve de facto as factories for their instances, no need of additional boilerplate.
  • Visitor: in Clojure, you have multimethods to help with this problem.
  • etc.

Most information about this topic is annectodical. You can check the links in my question. That would be nice to have a more complete coverage of this topic, sadly I've never found one.

Upvotes: 1

Related Questions