r/programming • • Dec 08 '13

Design Pattern Cheat Sheet

http://www.celinio.net/techblog/wp-content/uploads/2009/09/designpatterns1.jpg
1.7k Upvotes

273 comments sorted by

View all comments

3

u/[deleted] Dec 09 '13 edited Dec 09 '13

I usually find Design Patterns materials frivolous/unnecessary, but I really liked this one for being direct to the point!

The "idea" is the part I think can be relevant. The diagrams are OOP-dependent, but the text can be implemented in any paradigm/way, sometimes in a very simple way:

  • 'Visitor' - just a function map

  • 'Factory' - type inferring can be used, in most cases, as a default "built-in" factory.

6

u/[deleted] Dec 09 '13

[removed] — view removed comment

5

u/Peaker Dec 09 '13

The Visitor Pattern gives you a cumbersome, but type safe encoding of a closed sum type, in a language that has products (tuples/class fields) and exponents (functions) but doesn't have closed sum types.

How would a function map give you type safety around the sum type encoding?