Design Patterns Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the 3 categories of design patterns?

A
  • Creational
  • Structural
  • Behavioural
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are creational design patterns?

A

Creational design patterns are patterns that control how objects are created

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are structural design patterns?

A

Creational design patterns are patterns that are concerned with how classes and objects can be composed, to form larger structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are behavioural design patterns?

A

Behavioural patterns are common patterns for facilitating elegant communication between objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are examples of creational design patterns?

A
  • The Singleton pattern, for ensuring only a single instance of a class can exist
  • The Abstract Factory pattern, for creating an instance of several families of classes
  • The Prototype pattern, for starting out with an instance that is cloned from an existing one
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are examples of structural design patterns?

A
  • The Adapter pattern, for creating an interface to enable classes that normally can’t work together, to work together.
  • The Bridge pattern, for splitting a class that should actually be one or more, into a set of classes that belong to a hierarchy, enabling the implementations to be developed independently of each other.
  • The Decorator pattern, for adding responsibilities to objects dynamically.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are examples of behavioural design patterns?

A
  • The Template pattern, for deferring the exact steps of an algorithm to a subclass.
  • The Mediator pattern, for defining the exact communication channels allowed between classes.
  • The Observer pattern, for enabling classes to subscribe to something of interest, and to be notified when a change occurred.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Observer design pattern?

A

Observer is a behavioural design pattern that lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.

Also known as: Event-Subscriber, Listener

An Observer (usually inherited from an abstract base class) keeps a list of subscribers, which are notified on changes. The subscribers itself also inherit from an abstract base class together with the update() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Adapter design pattern?

A

Adapter is a structural design pattern that allows objects with incompatible interfaces to collaborate.

Also known as: Wrapper

Use the Adapter class when you want to use some existing class, but its interface isn’t compatible with the rest of your code.
The Adapter pattern lets you create a middle-layer class that serves as a translator between your code and a legacy class, a 3rd-party class or any other class with a weird interface.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly