Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Adapting Design Patterns to a Multi Paradigmatic World

Adapting Design Patterns to a Multi Paradigmatic World

How to adapt the classic GOF concepts to a multi paradigm language such as Python

Lia Nemeth

April 17, 2018
Tweet

Other Decks in Programming

Transcript

  1. The Gang of Four (GoF) Published in 1994 Inspired by

    Christopher Alexander Patterns have: - Name - Problem - Solution - Consequences
  2. These design patterns are not universal They are closely related

    to languages such as C++ and Java ¨The choice of programming language is important because it influences one's point of view." (GoF, 1994)
  3. But knowing reusable design elements can still be useful And

    some patterns can be adapted for the multi-paradigmatic and dynamic nature of Python
  4. Don't be object obsessed In 1994, Object Orientation was the

    shiny new thing and this influenced the GoF book
  5. The Strategy pattern can be easily adapted to use functions

    if they are first class elements of the language.
  6. Singleton is one of the most famous design patterns It's

    a class that allows a single object to be instantiated
  7. Alex Martelli proposes Borg instead of singleton. It can have

    multiple objects, but they all share state
  8. Conclusion Patterns can be useful, they are a great way

    to communicate an idea and getting to know them can bring good solutions to problems we face But always be cautious before blindly implementing them and think creatively on how they can be used