Quiz 2 Flashcards

1
Q

List the 4 common design patterns.

A
  1. Singleton
  2. Factory
  3. Observer
  4. Adapter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Purpose of ‘Factory’ design pattern?

A

Provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.

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

Purpose of ‘Singleton’ design pattern?

A

ensures that a class has only one instance, while providing a global access point to this instance.

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

Purpose of ‘Observer’ design pattern?

A

lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.

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

Purpose of ‘Adapter’ design pattern?

A

Allows objects with incompatible interfaces to collaborate.

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

what are the three categories of design patterns?

A
  1. Creational
  2. Structural
  3. Behavioural
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the ‘SOLID’ principle?

A
  • Single Responsibility Principle (high cohesion, low coupling)
  • Open/Closed Principle
  • Liskov Substitution Principle
  • Interface Segregation Principle
  • Dependency Inversion Principle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Single Responsibility principle?

A

A class should have only a single responsibility.

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

What is Open/Closed Principle?

A

A class must be closed for internal change but open for extension.

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

What is Liskov Substitution Principle?

A

Objects of a supertype in a program may be replaced with objects of a subtype without altering any desirable properties of the program.

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

What is Dependency Inversion Principle?

A

Depends on abstractions on implementations.

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

What is Interface Segregation Principle?

A

No client should be forced to depend on methods it does not use.

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

What is the difference between ‘technical debt’ and ‘code smell’?

A

Technical debts are choices that are done for fast initial gains but are counterproductive in long term.
Code smells are signs of weak designs and coding.

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