Design patterns Flashcards

Study and internalize design patterns

1
Q

What is dynamic binding?

A

Dynamic binding, also called dynamic dispatch, is the process of linking procedure call to a specific sequence of code (method) at run-time. Dynamic binding is also known as late binding or run-time binding. Dynamic binding is an object oriented programming concept and it is related with polymorphism and inheritance.

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

What are the 4 main tenets of OO?

A

Abstraction
Polymorphism
Inheritance
Encapsulation

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

What is polymorphism in OO?

A

A property of OO in which an abstraction operation may be performed in different ways in different classes, but share an interface.

Also can mean multiple methods of the same name but different signature.

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

What is an OCL

A

Object constraint language. A specification language designed to formally specify constraints in software modules. An OCL expression specifies a logical fact about the system that must remain true.
What is the Chain of Responsibility pattern? Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

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

What is the Command pattern?

A

Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.

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

What design pattern avoids coupling the sender of a request to its receiver by giving more than one object a chance to handle the request?

A

Chain of Responsibility

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

What design pattern encapsulates a request as an object, thereby letting you parameterize clients with different requests?

A

Command pattern

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

What is the Interpreter pattern?

A

Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.

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

What design pattern, given a language, defines a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language?

A

Interpreter pattern

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

What is the Iterator pattern?

A

Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

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

What design pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation?

A

Iterator pattern

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

What is the Mediator pattern?

A

Defines an object that encapsulates how a set of objects interact. Promotes loose coupling by keeping objects from referring to each other explicitly and it lets you vary their interactions independently.

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

What design pattern defines an object that encapsulates how a set of objects interact?

A

Mediator pattern

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

What is the Memento pattern?

A

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restore to this state later.

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

What design pattern captures and externalize an object’s internal state so that the object can be restore to this state later?

A

Memento pattern

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

What is the Observer pattern?

A

Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

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

What design pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically?

A

Observer pattern

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

What is the State pattern?

A

Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.

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

What design pattern allows an object to alter its behavior when its internal state changes?

A

State pattern

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

What is the Strategy pattern?

A

Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Lets the algorithm vary independently from clients that use it.

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

What design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable, and lets the algorithm vary independently from clients that use it?

A

Strategy pattern

22
Q

What is the Template Method pattern?

A

Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. Lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure.

23
Q

What design pattern defines the skeleton of an algorithm in an operation, deferring some steps to subclasses?

A

Template Method pattern

24
Q

What is the Visitor pattern?

A

Represents an operation to be performed on the elements of an object structure. Lets you define a new operation without changing the classes of the elements on which it operates.

25
Q

What design pattern represents an operation to be performed on the elements of an object structure and lets you define a new operation without changing the classes of the elements on which it operates?

A

Visitor pattern

26
Q

What is the Adapter pattern?

A

Converts the interface of a class into another interface clients expect. Lets classes work together that couldn’t otherwise because of incompatible interfaces.

27
Q

What design pattern converts the interface of a class into another interface clients expect?

A

Adapter pattern

28
Q

What is the Bridge pattern?

A

Decouples an abstraction from its implementation so that the two can vary independently.

29
Q

What design pattern decouples an abstraction from its implementation so that the two can vary independently?

A

Bridge pattern

30
Q

What is the Composite pattern?

A

Compose objects into tree structures to represent part-whole hierarchies. Lets clients treat individual objects and compositions of objects uniformly.

31
Q

What design pattern composes objects into tree structures to represent part-whole hierarchies?

A

Composite pattern

32
Q

What is the Decorator pattern?

A

Attaches additional responsibilities to an object dynamically. Provides a flexible alternative to sub-classing for extending functionality.

33
Q

What design pattern attaches additional responsibilities to an object dynamically and provides a flexible alternative to sub-classing for extending functionality?

A

Decorator pattern

34
Q

What is the Facade pattern?

A

Provides a unified interface to a set of interfaces in a subsystem. Defines a high-level interface that makes the subsystem easier to use.

35
Q

What design pattern provides a unified interface to a set of interfaces in a subsystem and defines a high-level interface that makes the subsystem easier to use?

A

Facade pattern

36
Q

What is the Flyweight pattern?

A

Uses sharing to support large numbers of fine-grained objects efficiently.

37
Q

What design pattern uses sharing to support large numbers of fine-grained objects efficiently?

A

Flyweight pattern

38
Q

What is the Proxy pattern?

A

Provides a surrogate or placeholder for another object to control access to it.

39
Q

What design pattern provides a surrogate or placeholder for another object to control access to it?

A

Proxy pattern

40
Q

What is the Abstract Factory pattern?

A

Provides an interface for creating families of related or dependent objects without specifying their concrete class.

41
Q

What design pattern provides an interface for creating families of related or dependent objects without specifying their concrete class?

A

Abstract Factory pattern

42
Q

What is the Builder pattern?

A

Separates the construction of a complex object from its representation, so the same construction process can create different representations.

43
Q

What design pattern separates the construction of a complex object from its representation, so the same construction process can create different representations?

A

Builder pattern.

44
Q

What is the Factory Method pattern?

A

(Technically it’s an idiom)

Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Lets a class defer instantiation to subclasses.

45
Q

What design pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate?

A

Factory method (technically an idiom, not a design pattern)

46
Q

What is the Prototype pattern?

A

Specifies the kinds of objects to create using a prototypical instance, and creates new objects by copying this prototype.

47
Q

What design pattern specifies the kinds of objects to create using a prototypical instance, and creates new objects by copying this prototype?

A

Prototype pattern

48
Q

What is the Singleton pattern?

A

Ensures a class only has one instance and provides a global point of access to it.

49
Q

What design pattern ensures a class only has one instance and provides a global point of access to it?

A

Singleton pattern

50
Q

What are design patterns?

A

Recurring, reusable solutions to common class and class relationship problems.