Patrones Flashcards

1
Q

Types of Design Patterns

A

Creational, structural and behavioural

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

Elements of the Builder Pattern

A
  • Builder interface which defines building steps
  • Concrete builders that implement the interface and can return a result
  • Director which contains a classes and runs the build steps (without returning the result)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Elements of the Factory Pattern

A
  • Factory interface
  • Concrete factories which implement the interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Example of Factory Pattern

A

An abstract factory for a monster class, and three concrete factories according to the difficulty of the generated monsters

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

Elements of an Abstract Factory pattern

A
  • An AbstractFactory interface
  • Concrete factories that inherit from the AbstractFactory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Example of Abstract Factory pattern

A

In a game, factories of different monsters, with different difficulties

Or UI component factories, where there are two factories, one for Windows and one for macOS, each capable of creating different types of componentes.

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

Elements of the (Object) Adapter Pattern

A
  • A Client Interface that is understood by the Client
  • An Adapter that inherits from the desired Client Interface, implementing it while wrapping a service
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Elements of the Composite Pattern

A
  • An interface component for the Client to consume
  • A Leaf basic node, that inherits from the Interface. (This is the minimal object)
  • A Container (Composite) that is composed by leaves or other containers. It interacts with it’s children via the Interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Elements of the Decorator Pattern

A
  • A Base Decorator, which envelops a class and emulates its interface, that the Client Consumes
  • Concrete decorators that inherit from the Base Decorator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Elements of the Observer pattern

A
  • A Publisher class which has a list of subscribers, and has methods for subscribing, unsubscribing and notifying its subscribers
  • A Subscriber interface to receive updates
  • Concrete Subscribers which do things when they receive an update
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Elements of the Facade Pattern

A
  • A Facade, which is a class that deals with a lot of Subsystem classes, and simplifies the system complexity
  • Additional Facades can be created for other operations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Elements of the Command pattern

A
  • A Command interface, which describes methods to execute commands
  • Concrete commands that do something when their execute methods are called
  • A client that creates and configures the commands
  • Invokers or Senders which can store and run commands.
  • (Optionally) a Receiver which does the actual business logic behind a command
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Elements of a Strategy pattern

A
  • A Context which can store a strategy, change their strategy using a method and do something using the strategy.
  • A strategy interface
  • Concrete strategies implementing the interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Ruby method equivalent of __init__

A

def initialize(args)...end

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

Para exponer atributos en Ruby, es necesario usar…

A

attr_accesor, attr_reader o attr_writer para crear getters y setters, o implementarlos a mano

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