· 3 min read

Learn Design Patterns and SOLID: 60 Flashcards on the Gang of Four and OOP Basics

Learn all 23 Gang of Four design patterns and the 5 SOLID principles with 60 flashcards, plus tips to tell Adapter, Decorator, Proxy, State and Strategy apart.

Class diagram tree, building blocks, gear and puzzle piece among flashcards

Studying. But it's also a video game. 🎮

Flashcards, quizzes and games that make you actually remember.

Start playing — it's free

Posted by

Design patterns are easy to recognize when you read about them and hard to tell apart when an interviewer asks. The Flip It deck Design Patterns & OOP/SOLID Principles (deck code YM2244, 60 cards) has two blocks. Cards 1-23 list the 23 Gang of Four patterns, each labelled Creational, Structural or Behavioral. Cards 24-60 cover OOP vocabulary and the five SOLID principles.

Study this deck: Design Patterns & OOP/SOLID Principles

1 / 10
Question

Abstract Factory (Creational)

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Sample cards

FrontBack
Builder (Creational)Constructs complex objects by separating construction and representation
Prototype (Creational)Creates objects by cloning an existing object. Useful when creation is expensive
Bridge (Structural)Decouples an abstraction from its implementation so that the two can vary independently
Flyweight (Structural)Shares common state among multiple objects
Memento (Behavioral)Captures and externalizes object state without violating encapsulation
Template Method (Behavioral)Defines the skeleton of an algorithm, deferring steps to subclasses
Open/Closed Principle (OCP)Software entities should be open for extension, but closed for modification
Dependency Inversion Principle (DIP)Depend upon abstractions, not concretes
First language with primary OOP featuresSimula, Norway, 1961-1967: classes, inheritance, dynamic binding

Everything in the deck

Creational: Abstract Factory, Builder, Factory Method, Prototype, Singleton. Structural: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy. Behavioral: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor. OOP: encapsulation, information hiding, class vs object, instance vs class variable, constructor, abstract class, inheritance, multiple inheritance, mixin, polymorphism, dynamic dispatch, message passing, this/self, delegation, composition over inheritance, prototype-based programming, access modifiers, cohesion, coupling, the God object anti-pattern and the circle-ellipse problem.

How to tell the patterns apart

Study the patterns that look alike side by side. Most confusion comes from patterns with the same structure but a different purpose. Adapter changes an interface, Decorator adds behaviour behind the same interface, Proxy controls access through the same interface, and Facade simplifies a whole subsystem. State and Strategy are also built the same way: a Strategy is picked by the client, while a State object is swapped out by the object itself when its internal state changes. Make one flashcard per pair that asks "what's the difference?" and you will get more out of it than from 23 separate definitions.

Name a real example for each pattern. The backs are copied from textbook definitions. Add a concrete case to each one: Iterator is a for…of loop, Observer is an event listener, Command is an undo stack, and Composite is a DOM tree. When you can name a real use, you understand the pattern.

Duplicates and gaps

  • Cards 55-57 (Singleton, Factory and Observer "pattern") repeat cards 5, 3 and 19. Card 48 (behavioral subtyping) repeats card 36 (Liskov).
  • Card 58 only says the circle-ellipse problem is "a classic problem". Rewrite the back: a Circle subclass breaks Ellipse's setWidth, which is a textbook violation of the Liskov principle.
  • The deck has no cards on the GoF book (1994) or on who coined SOLID (Robert C. Martin's principles, acronym by Michael Feathers), and the only anti-pattern is the God object.

For the distributed-systems side, continue with System Design & API Design Patterns.

Find Design Patterns & OOP/SOLID Principles (YM2244) in the library at flip-it.app.

Ready to learn faster? 🚀

Join FLIP IT for free and turn studying into a game.

Create my free account