'Design Patterns in Smalltalk [closed]

It is often said that design patterns are mostly used in statically typed languages like C++ and Java, which I also agree. But in this article Robert Martin wrote

What a strange thing to say. Smalltalk, a dynamic language, played a significant role.

Since I don't have experience in Smalltalk I would like to ask if patterns like Strategy or Visitor are much used in Smalltalk? I don't think you need them in a "dynamic language"



Solution 1:[1]

Historically, Kent Beck was among the first to apply the design pattern to programming with Ward Cunningham, and this was mostly applied to Smalltalk.
See https://en.wikipedia.org/wiki/Software_design_pattern

He popularized some of these patterns in 1996 book Smalltalk best practice patterns.
See https://en.m.wikipedia.org/wiki/Kent_Beck

Even if the work of the gang of four was published in 1994 before the book of Kent Beck, it should not really be a surprise to find a lot of these patterns in Smalltalk.

The irony is that these design patterns have tremendously helped statically typed languages once applied to them.

Solution 2:[2]

The article you mention explains pretty well what Design Patterns are, and I'd add a few more details in the context of your question.

Design patterns provide well understood ways of increasing software quality, by basically lowering coupling and increasing cohesion. These two properties are inherent of any piece of software, no matter if it is written in statically typed, dynamically typed, message based/object oriented, functional or imperative languages.

While the patterns can slightly differ between dynamically and statically typed languages, they nevertheless provide useful conceptualisations of how code should be designed.

Actually, many (if not all) of the authors of the original design patterns book were very well versed smalltalkers, and probably discovered those patterns while working with Smalltalk code. There are hundreds of mentions to Smalltalk in the original book, and many of the original patterns are applied in Smalltalk systems.

If you open any Smalltalk, the visitor is one of the most easily distinguishable, because of its particular visit/accept api, which is used to traverse many tree-like structures like parse trees in the compiler, or nodes in a hierarchy of user-interface elements.

Solution 3:[3]

An excellent book on how to implement design patterns in Smalltalk is: https://www.amazon.com/Design-Patterns-Smalltalk-Companion/dp/0201184621

If you can read a little bit of Smalltalk I think this book gives a much clearer view of the standard Design Patterns than the GoF-book which presents them in C++.

Why is that you might ask? I think it is because Smalltalk has no static type-declarations so the code is shorter and easier to understand, in my view. So you grasp the "shape" of the patterns more easily.

I especially liked the presentation of Visitor in this book.

Solution 4:[4]

Some fairly extensive parts of the draft of the Smalltalk companion book is available for free (legally!) at http://rmod-files.lille.inria.fr/FreeBooks/SmalltalkDesignPatternCompanion

Worth a look to decide if you might want to buy a copy.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 melkyades
Solution 3 Panu Logic
Solution 4 timRowledge