week 8 Flashcards

1
Q

Structural design pattern

A

focuses on simplifying the design of complex systems by identifying relationships between classes and objects. These patterns primarily deal with how classes and objects are composed to form larger structures, making it easier to manage and modify them.

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

behavioural pattern

A

They focus on the interaction between objects and the responsibility of objects.

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

creational

A

deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.

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

Singleton

A

Singleton Pattern is a creational design pattern that lets you ensure
that a class has only one instance, while providing a global access point
to this instance

used often in logging in when we only need one instance of logging in service or one data base

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

How to code singleton in Java

A

public class Singleton {
private static Singleton uniqueInstance;
private Singleton() {
}
public static Singleton getInstance() {
if (uniqueInstance == null) {
return new Singleton(); //
} else {
return uniqueInstance;
}
}
//other methods
}

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

Strategy is a …… pattern

A

behavioural pattern

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

One of the key benefits of using the strategy pattern is that it allows the client to choose the appropriate algorithm at runtime, promoting flexibility and easy extension.

A

read

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

read

A

The strategy pattern promotes the “Open/Closed” principle of object-oriented design, allowing the system to be easily extended with new algorithms without modifying existing code.

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

what does facade do
[structural]

A

The primary purpose of the Facade Pattern is to hide the complexities of a subsystem and provide a single, unified interface for the client.

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

Facade look at the week 8 slides and video for facade . too hard to explain via words

A

do this

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

It is hard to remove a specific wrapper from the wrappers stack.

It is hard to implement a decorator in such a way that its behaviour doesn’t depend on the
order in the decorators stack.

eg in a file system you have a certain order
creating file
then wrapping in a file input stream
then wrapping it in a buffered input stream

HAS TO BE IN THIS ORDER

A

read

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