design patterns Flashcards

1
Q

what are design patterns

A

reusable solutions to common problems that occur in software design

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

what are the 4 elements of a design pattern

A

name; description of the pattern in 2 or less words
problem; when you should use the pattern
solution; elements that make up the design and interactions responsibilities and relationships
consequences; trade offs of using the pattern

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

what are the 3 categories of design patterns

A

creational; techniques to create objects
structural; how classes are imposed in larger structures
behavioural; communication between objects

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

what is the observer design pattern

A

behavioural design pattern that allows you to define a subscription mechanism to notify other objects about any changes made in the object their observing

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

subject/publisher

A

the object that is changing state and informs observers

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

observers/subscribers

A

dynamically attached to the subject and can subscribe to event notifications

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

subject as an abstract class

A

abstract class defines add remove and notify observers
the concrete subject extends the abstract class
the concrete observer implements the observer interface and registers with concrete subjects to receive updates

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

subject as an interface

A

can add remove and notify observers
the concrete subject implements this and keeps a list of the observers and notifies them
the concrete observer implements the observer interface and registers with concrete subjects to receive updates

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

what is an adaptor design pattern

A

structural design pattern that converts the interface of a class into an interface that the client expects

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

what are the 4 classes needed for the adaptor

A

client; who wants to use the interface
target; the interface that the client uses
adaptor; adapts the adaptee to the target interface
adaptee; the existing interface that needs changing

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

class adaptor

A

adaps the adaptee by inheriting it and implementing the target interface

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

object adaptor

A

relies on composition
the adaptor implements the target interface and contains the adaptee instance to which it forwards the request

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