Learn: Structural Patterns in ES6+ using Game of Thrones

Riccardo Canella
Javascript by doing
5 min readOct 22, 2021


In software engineering, a Design Pattern describes an established solution to the most commonly encountered problems in software design. It represents the best practices evolved over a long period through trial and error by experienced software developers.

In this article we will talk about the Structural Design Patterns.
Structural Patterns are design patterns that ease the design by identifying a simple way to realize relationships among entities.

The most common Structural Patterns are:

  • Adapter
  • Decorator
  • Façade
  • Flyweight
  • Proxy

Adapter Pattern

The adapter Pattern is a structural pattern where the interface of one class is translated into another. This pattern lets classes work together that could not otherwise because of incompatible interfaces.

Let’s pretend that the Targaryen house wants to go to war with all its strength, both the Unsullied and the Dragons, but Daenerys wants to find a unique way to ask both of them to kill someone.

According to the “Adapter” pattern, we will need:

* An Unsullied class
* A Dragon class
* An Adapter class to transform the burn method of dragon to the common kill method

When to use the Adapter Pattern?

  • When new components and modules need to be integrated to work with existing ones in an application or when part of code is refactored with improved interface but still needs to work with old parts.
  • When you find an external library that manages corner cases and you want to integrate it with your code

Decorator Pattern

The decorator pattern is a structural design pattern that focuses on the ability to add…



Riccardo Canella
Javascript by doing

Riccardo Canella @ricanella92 Love #basket, #bike and #HIMYM since my childhood. #Fullstack #Javascript addicted - https://canellariccardo.it