Structural Design Patterns Flashcards

1
Q

Provide definition of Adapter pattern

A

Pattern that allows objects with
incompatible interfaces to collaborate

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

Provide definition of Bridge pattern

A

Bridge is a structural design pattern that lets you split a large class or a set of closely related classes into two separate
hierarchies—abstraction and implementation—which can be
developed independently of each other

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

What means Abstraction in Bridge pattern

A

Abstraction (also called interface) is a high-level control layer for some entity. This layer isn’t supposed to do any real work
on its own. It should delegate the work to the implementation layer (also called platform).

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

What means Impelementation in Bridge pattern

A

An interface or abstract class defining the low-level operational methods. This acts as a base for the concrete implementation

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

Provide definition od Composite pattern

A

Composite is a structural design pattern that lets you compose objects into tree structures and then work with these structures as if they were individual objects

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

What principle can be violated by Composite pattern and why?

A

Interface Segregation Principle can violated when Composite definies the methods Add, Remove. They will be empty in the leaf
class. However, the client will be able to treat all the elements equally, even when composing the tree

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

Provide definition for Decorator pattern

A

Structural design pattern that lets you attach
new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors

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

What means that inheritance is static

A

You can’t alter the behavior of an existing
object at runtime. You can only replace the whole object with another one that’s created from a different subclass

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

Which pattern manages the life
cycle of its service object on its own

A

Proxy

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

Provide definition for Facade pattern

A

Structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of
classes

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

Facade pattern maigh provide limited functionality

A

A facade might provide limited functionality in comparison to working
with the subsystem directly. However, it includes only those
features that clients really care about

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

What is the purpose of additional facade

A

An Additional Facade class can be created to prevent polluting a single facade with unrelated features that might make it yet
another complex structure. Additional facades can be used by
both clients and other facades

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

Provide a definition for Flyweight pattern

A

Structural design pattern that lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object

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

State of an object with constant data of which lives within the object; other objects can only read it, not change it.

A

Intrinsic state

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

The object’s state, often altered “from
the outside” by other objects, is called

A

Extrinsic state

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

What you can say about Flyweight and immutability

A

You have to make sure that its state can’t be modified.
A flyweight should initialize its state just once, via constructor parameters. It shouldn’t expose any setters or public fields to
other objects.

17
Q

What you can say about Flayweight fatory

A

It is teh factory method pattern. The method accepts the intrinsic state of the desired flyweight
from a client, looks for an existing flyweight object matching this
state, and returns it if it was found. If not, it creates a new fly-
weight and adds it to the pool

18
Q

Provide a definition for Proxy pattern.

A

Proxy is a structural design pattern that lets you provide a
substitute or placeholder for another object. A proxy controls
access to the original object, allowing you to perform
something either before or after the request gets through to
the original object

19
Q

What is an alternative implementation of proxy when extracting interface is not possible

A

Make the proxy a subclass of the service class, and this way it’ll inherit the interface of the service

20
Q

Service class should be passed to Proxy via constructor or should be created internally be Proxy

A

Usually, proxies create and manage the whole life cycle of their servers. In rare occasions, a service is
passed to the proxy via a constructor by the client